<?php
include('member_resume_controller.php');
class MemberController extends MemberResumeController {
	
	var $name = 'Member';
	
	function ajax_city() {
		$this->layout = 'ajax';
		$p = $this->data['Member']['address_nation_id'];
		if($this->Valid->number($p)) {
			$condition = " kbn ='city_id' and pid=" . $p;
			$city_list = $this->SysParams->generateList($condition, 'sort');
			$this->set("city_list", $city_list);
		}
	}
	
	function birthday_yy() {
		$this->layout = 'ajax';
		$y = $this->data['Birthday']['yyyy'];
		$m = $this->Session->read("mm");
		
		$daylist = array();
		$this->Session->write('yyyy', $y);
		if ($m != null) {
			
			$this->Session->write('yyyy', $y);
			if ($m == 1 || $m == 3 || $m == 5 || $m == 7 || $m == 8 || $m == 10 || $m == 12) {
				for($i = 1; $i <= 31; $i++) {
					$daylist[$i] = $i;
				}
			}
			if ($m == 4 || $m == 6 || $m == 9 || $m == 11) {
				for($i = 1; $i <= 30; $i++) {
					$daylist[$i] = $i;
				}
			}
			if ($y % 4 == 0 && $m == 2) {
				$index = 0;
				for($i = 1; $i <= 29; $i++) {
					$daylist[$i] = $i;
				}
			} else if ($y % 4 != 0 && $m == 2) {
				for($i = 1; $i <= 28; $i++) {
					$daylist[$i] = $i;
				}
			}
		}
		$this->set("daylist", $daylist);
	}
	
	function ajax_birthday() {
		$this->layout = 'ajax';
		$y = $this->Session->read('yyyy');
		//$m=$this->data['Birthday']['mm'];
		$m = (strlen($this->data['Birthday']['mm']) > 1) ? $this->data['Birthday']['mm'] : '0' . $this->data['Birthday']['mm'];
		$daylist = array();
		if ($y != null && $y != "") {
			if ($m == 1 || $m == 3 || $m == 5 || $m == 7 || $m == 8 || $m == 10 || $m == 12) {
				for($i = 1; $i <= 31; $i++) {
					$daylist[$i] = $i;
				}
			}
			if ($m == 4 || $m == 6 || $m == 9 || $m == 11) {
				for($i = 1; $i <= 30; $i++) {
					$daylist[$i] = $i;
				}
			}
			if ($y % 4 == 0 && $m == 2) {
				$index = 0;
				for($i = 1; $i <= 29; $i++) {
					$daylist[$i] = $i;
				}
			} else if ($y % 4 != 0 && $m == 2) {
				for($i = 1; $i <= 28; $i++) {
					$daylist[$i] = $i;
				}
			}
			if ($_SESSION['yyyy'] != null) {
				//$_SESSION['yyyy'] = null;
			}
		} 
		
		$this->Session->write("mm", $m);
		$this->set("daylist", $daylist);
	}
	
	function index() {
		if (isset($this->rdAuth->login_id)) {
			$this->redirect('/Member/detail');
		}
	}
	
	function login() {
		
		$message = $this->CompanyAccount->Login_Valid($this->Valid, 
			$this->params['data']);
		
		$username = $this->params['data']['CompanyAccount']['login_id'];
		$pwd = $this->params['data']['CompanyAccount']['login_pwd'];
		
		//LOGIN ID CHECK
		

		$check_name = $this->CompanyAccount->find(
			"login_id = '" . $username . "'");
		
		if ($check_name['CompanyAccount']['id'] == null && $username != null) {
			$this->set('message', 
				$this->Valid->tagErrorMsg('incorrect', 
					'CompanyAccount/login_id'));
			var_dump($pwd);
			$this->params['data']['CompanyAccount']['login_pwd'] = '';
			$this->render('index');
			exit();
		}
		
		//PASSWORD CHECK	
		$condition = "login_id = '" . $username . "'" . " AND login_pwd = '" . $pwd . "' AND deleted is null";
		$check_pwd = $this->CompanyAccount->find($condition);
		if ($check_pwd == null && $pwd != null) {
			
			$this->set('message', 
				$this->Valid->tagErrorMsg('incorrect', 
					'CompanyAccount/login_pwd'));
			$this->params['data']['CompanyAccount']['login_pwd'] = '';
			$this->render('index');
			exit();
		}
		
		if ($message) {
			//validate failed
			$this->set("message", $message);
			
			$this->render('index');
			
			exit();
		} else {
			//validate success
			if ($this->params['data']['CompanyAccount']['save'] == 1) {
				$this->rdCompany->set($check_pwd['CompanyAccount']);
			}
			
			$this->redirect('general/index');
			exit();
		}
	
	}
	
	function mail_add() {

	}
	
	function reg_mail_confirm() {
		$message = $this->CompanyAccount->Email_Valid($this->Valid, 
			$this->params['data']);
		if ($message) {
			//validate failed
			$this->set("message", $message);
			$this->render('reg_mail_add');
			exit();
		} else {
			//validate success
			$this->render('mail_success');
			exit();
		}
	}
	function reg_add() {
		
		if (empty($this->data)) {
			$this->data = $this->Session->read('reg_info');
			$this->set('powers', 
				$this->SysParams->generateList(
					$condition = "kbn='password_question_id'"));
			$this->render('reg_add');
			
			exit();
		}
		
		$pwd_remain_id = $this->SysParams->read(null, 
			$this->data['Company']['pwd_remain_id']);
		$this->data['Company']['pwd_remain_id'] = $pwd_remain_id['SysParams']['name'];
		$this->set('powers', 
			$this->SysParams->generateList(
				$condition = "kbn='password_question_id'"));
	
	}
	function reg_confirm() {
		$this->Session->write('reg_info', $this->data);
		$pwd_remain_id = $this->SysParams->read(null, 
			$this->data['Company']['pwd_remain_id']);
		$this->data['Company']['pwd_remain_id'] = $pwd_remain_id['SysParams']['name'];
		$message = $this->CompanyAccount->Reg_Valid($this->Valid, $this->data);
		$this->set('powers', 
			$this->SysParams->generateList(
				$condition = "kbn='password_question_id'"));
		
		if ($message) {
			//validate failed
			if ($this->params['data']['Company']['agree'] == 2) {
				$message .= $this->Valid->tagErrorMsg('disagree', 
					'Company/agree');
			}
			$this->set("message", $message);
			$this->render('reg_add');
			exit();
		} else {
			//validate success
			$this->render('reg_confirm');
			exit();
		}
	}
	
	function reg_finish() {
		
		$id = $this->data['CompanyAccount']['id'];
		$this->CompanyAccount->save($this->Session->read('reg_info'));
		$data = $this->Session->read('reg_info');
		$data['Company']['update_id'] = 9;
		$this->Company->save($data);
		$this->Session->del('reg_info');
	}
	function email_add() {
		if (empty($this->data)) {
			$this->data = $this->Session->read('mail_info');
		}
	}
	
	function email_confirm() {
		$this->Session->write('mail_info', $this->data);
		
		$message = $this->CompanyAccount->Pwd_Email_Valid($this->Valid, 
			$this->params['data']);
		$par = $this->params['data']['CompanyAccount']['email'];
		$condition = "\"CompanyAccount\".email=" . "'$par'" . " and \"CompanyAccount\".deleted is null";
		$email = $this->Company->findAll($condition, null);
		$val = $email[0]['CompanyAccount']['company_id'];
		$data = $this->Company->findAll(
			"\"Company\".id =" . $val . " and \"Company\".deleted is null");
		//		var_dump($data);
		if (empty($data) && !$message) {
			$message .= $this->Valid->tagErrorMsg('not_exist', 'Company/email');
		}
		
		if ($message) {
			//validate failed
			

			$this->set("message", $message);
			$this->render('email_add');
			exit();
		} else {
			$condition = "\"Company\".deleted is null AND \"Company\".id=" . "'$val'";
			$this->data = $this->Company->find($condition);
			var_dump($this->data);
			$this->Session->write('answer_info', $this->data);
			//validate success
			$this->render('email_confirm');
			exit();
		}
	
	}
	
	function pwd_add() {
		if (empty($this->data)) {
			$this->data = $this->Session->read('answer_info');
			$this->data['Company']['user_answer'] = $this->data['Company']['pwd_remain_answer'];
			$this->render('email_confirm');
			exit();
		}
		$user_answer = $this->params['data']['Company']['user_answer'];
		$condition = "\"Company\".pwd_remain_answer=" . "'$user_answer'" . " and \"CompanyAccount\".deleted is null";
		$answer = $this->Company->findAll($condition, null);
		if (empty($answer)) {
			$this->set('message', 
				$this->Valid->tagErrorMsg('incorrect', 
					'Company/pwd_remain_answer'));
			$this->data = $this->Session->read('answer_info');
			$this->render('email_confirm');
			exit();
		} 

		else {
			
			//validate success
			$this->render('pwd_add');
			exit();
		}
	}
	function pwd_save() {
		$message = $this->CompanyAccount->Pwd_Valid($this->Valid, 
			$this->params['data']);
		
		if ($message) {
			//validate failed
			$this->set("message", $message);
			$this->render('pwd_add');
			exit();
		} else {
			//validate success
			

			$id = $this->Session->read('answer_info');
			$info = array();
			$info['CompanyAccount']['login_pwd'] = $this->data['CompanyAccount']['login_pwd'];
			$info['CompanyAccount']['id'] = $id['Company']['id'];
			
			$this->CompanyAccount->save($info);
			$this->Session->del('answer_info');
			$this->Session->del('mail_info');
			$this->Session->del('reg_info');
			$this->render('pwd_finish');
			exit();
		}
	
	}
	//@author zhufeng
	function reg1() {
		
		$id = $this->rdAuth->id;
		if (!empty($id)) {
			$this->remmember();
			exit();
		} else {
			$this->pageTitle = "カモメ会員登録";
		}
	}
	//@author zhufeng
	function doReg1() {
		//$hour = $this->Prop->getValue ( 'config.register_cancel_hour' );//@author wangyuhua この行を注釈する
		//$canceltime = date ( 'Y-m-d H:i:s', mktime ( date ( "H" ) - $hour ) );//@author wangyuhua この行を注釈する
		$p = $this->data;
		$message = $this->Valid->ErrorMsg($this->data, 'Member/email', 
			'required');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/email', 
			'confirm');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/email', 'email');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/email', 
			'mbmaxlength', '80');
		if (empty($message)) {
			
			if ($p['Member']['email'] == $p['Member']['email_confirm']) {
				$myEmail = $p['Member']['email'];
				$this->Encrypt->encode($myEmail);
				//@author wangyuhua 2012-02-16 update start
				$exist_email = $this->Member->checkEmail(
					$myEmail, $p['Member']['email'], null);
				if ($exist_email) {
					$data['name'] = $p['Member']['email'];
					$member_id = $this->Member->find(
						"\"Member\".member_role = 'visitor' AND \"Member\".email='$myEmail'");
					$timestamp = strtotime($member_id['Member']['created']);
					//$strTime = substr($member_id['Member']['created'],0,19);
					//$data['url']="member/reg3/".Md5($data['name']).$member_id['Member']['id'].str_replace(" ","",str_replace(":","",str_replace("-","",$strTime)));
					$data['url'] = "member/reg3/" . Md5(
						$data['name']) . $member_id['Member']['id'] . $timestamp;
					//@author wangyuhua 2012-02-16 update end
					$contents = $this->getMailTemplate(
						"member_regist_step1", $data);
					$subject = $this->Prop->getValue(
						'config.mail_title.member_regist_step1');
					$this->MailJob->saveMsg('web@rgf-hragent.com.cn', $data['name'], 
						$subject, $contents, "", 'info@rgf-hragent.com.cn');
					$this->pageTitle = "カモメ会員登録";
					
					$this->render('reg2');
					exit();
				} else {
					$message = $this->Valid->tagErrorMsg('register2', 
						'Company/email');
					$this->set("message", $message);
					$this->pageTitle = "カモメ会員登録";
					$this->render("reg1");
					exit();
				}
			}
			$message .= $this->Valid->tagErrorMsg('confirm', 'email', 'email1');
			$this->set("message", $message);
			$this->pageTitle = "カモメ会員登録";
			$this->render("reg1");
			exit();
		} else {
			
			$this->set("message", $message);
			$this->pageTitle = "カモメ会員登録";
			$this->render('reg1');
			exit();
		}
	
	}
	//@author zhufeng
	function reg2() {
		$this->pageTitle = "カモメ会員登録";
	}
	//@author zhufeng
	function reg3($str) {
		$str = $this->params['pass'][2];

		$this->pageTitle = "カモメ会員登録";
		$str = trim($str);
		//@author wangyuhua 2012-02-16 update start
		

		//$id=substr($str,32);//@author wangyuhua この行を注釈する
		$id = substr($str, 32, strlen($str) - 42);
		$id = 1;
		$creTime = substr($str, strlen($id) + 32, 10);
		$email2 = substr($str, 0, 32);
		//$con="\"Member\".id=".$id." and \"Member\".deleted is null";//@author wangyuhua この行を注釈する
		$conTime = date("Y-m-d H:i:s", $creTime);
		$hour = $this->Prop->getValue('config.register_cancel_hour');
		//日本時間より、一時間を加え
		$hour = $hour + 1;
		$strsql = "select to_char((current_timestamp - interval '" . $hour . " hours'),'yyyy-mm-dd hh24:mi:ss:ms') as dbtime";
		$timeNow = $this->Member->query($strsql);
		$dbTime = $timeNow[0][0]['dbtime'];
		
		//$actime = date ( "Y-m-d H:i:s", strtotime("-1 day") );
		$con = "\"Member\".\"id\"='" . $id . "' and \"Member\".\"deleted\" is null";
		
		$mem = $this->Member->find($con);
		//@author wangyuhua 2012-02-16 update end
		if (!empty($mem['Member']['name_kanji'])) {
			$this->showError('reg_key_date_error');
			exit();
		}
		if (!empty($mem)) {
			$email = $mem['Member']['email'];
			$email1 = Md5($email);
			if ($email1 == $email2) {
				$this->set("myMember", $mem);
				
				$condition = " kbn='nationality_id' and deleted is null";
				
				$country_list = $this->SysParams->generateList($condition, 
					'sort');
				$country_list2 = $this->SysParams->generateList(
					"kbn = 'country_id' and deleted is null", 'sort');
				$this->set("country_list", $country_list);
				$this->set("country_list2", $country_list2);
				
				$condition2 = " kbn ='city_id' and pid=1  and deleted is null";
				$city_list = $this->SysParams->generateList($condition2, 'sort');
				$this->set("city_list", $city_list);
				
				
				// @author wang.wei 2012/2/24 add start
				$this->init_reg3();
				$mem['Member']['member_overseas_edu_count']=1;
				$mem['Member']['member_overseas_work_count']=1;
				$mem['Member']['member_lang_count']=1;
				$mem['Member']['member_hope_work_location_count']=1;
				$mem['Member']['member_hope_worktype_count']=1;
				$mem['Member']['member_hope_category_count']=1;
				$mem['MemberExpWorktype']['exp_category']='';
				// @author wang.wei 2012/2/24 add end
				// @author wang.wei 2012/3/12 add start
				$mem['Member']['work_visa_flg']=2;
				// @author wang.wei 2012/3/12 add end
				//add by wang.wei 2012/3/22
				$count = $this->params['url']['toid'] == '' ? 1 : '';
				$this->set("exp_worktype_small_list".($count-1), array());
				$this->set("hope_worktype_small_list".$count, array());
				//add by wang.wei 2012/3/31
				$mem['Member']['return_url']=$str;
				
				$this->myInit();
				$this->Session->write("myMember", $mem);
				$this->set("myMember", $mem);
				$this->pageTitle = "カモメ会員登録";
				$y = date('Y');
				$yearlist = array();
				
				for($i = 1936; $i <= $y; $i++) {
					$yearlist[$i] = $i;
				
				}
				$this->set("yearlist", $yearlist);
				$monthlist = array();
				
				for($i = 1; $i <= 12; $i++) {
					$monthlist[$i] = $i;
				
				}
				$this->set("monthlist", $monthlist);
				$daylist = array();
				
				for($i = 1; $i <= 31; $i++) {
					$daylist[$i] = $i;
				
				}
				$this->set("daylist", $daylist);
				$this->render('reg3');
				exit();
			} else {
				$this->showError('reg_key_error');
				exit();
			}
		} else {
			$this->showError('reg_key_error');
			exit();
		}
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/27
	* */
	function init_reg3(){
		$this->init_member_overseas_edu();
		$this->init_member_overseas_work();
		$this->init_member_lang();
		$this->init_member_hope_work_location();
		$this->init_member_hope_worktype();
		
		$condition10 = "kbn='change_work_will' and deleted is null";
		$change_work_will_list = $this->SysParams->generateList($condition10);
		$this->set("change_work_will_list", $change_work_will_list);
		
		$condition12 = "kbn='income_cur' and deleted is null";
		$hope_income_cur_list = $this->SysParams->generateList($condition12);
		$this->set("hope_income_cur_list", $hope_income_cur_list);
		
		$exp_year_list = array();
		for($i = 1; $i <= 50; $i++) {
			$exp_year_list[$i] = $i;
		}
		$this->set("exp_year_list", $exp_year_list);
		
		$year = date('Y');
		$month = ltrim (date('m'),'0') + 1;
		$change_work_ym_list = array();
		for($i = 1; $i <= 12; $i++){
			if($month>12){
				$change_work_ym_list[($year+1).'年'.($month-12).'月までに'] = ($year+1).'年'.($month-12).'月（'.$i.'ヵ月後）までに';
			}else{
				$change_work_ym_list[$year.'年'.$month.'月までに'] = $year.'年'.$month.'月（'.$i.'ヵ月後）までに';
			}
			$month++;
		}
		$change_work_ym_list['まだ具体的には決めていない']='まだ具体的には決めていない';
		$this->set("change_work_ym_list", $change_work_ym_list);
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/24
	* */
	function init_member_overseas_edu(){
		$condition3 = " kbn='overseas_edu_period' and deleted is null";
		$overseas_edu_period_list = $this->SysParams->generateList($condition3, 'sort');
		$this->set("overseas_edu_period_list", $overseas_edu_period_list);
		
		$condition4 = " kbn='overseas_edu_purpose' and deleted is null";
		$overseas_edu_purpose_list = $this->SysParams->generateList($condition4, 'sort');
		$this->set("overseas_edu_purpose_list", $overseas_edu_purpose_list);
		
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/24
	* */
	function init_member_overseas_work(){
		$condition5 = " kbn='overseas_work_period' and deleted is null";
		$overseas_work_period_list = $this->SysParams->generateList($condition5, 'sort');
		$this->set("overseas_work_period_list", $overseas_work_period_list);
		
		$condition6 = " kbn='overseas_work_position' and deleted is null";
		$overseas_work_position_list = $this->SysParams->generateList($condition6, 'sort');
		$this->set("overseas_work_position_list", $overseas_work_position_list);
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/27
	* */
	function init_member_lang(){
		$condition7 = " kbn='language_level' and deleted is null";
		$language_level_list = $this->SysParams->generateList($condition7, 'sort');
		$this->set("language_level_list", $language_level_list);
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/27
	* */
	function init_member_hope_work_location(){
		$condition11 = "kbn='hope_work_location' and deleted is null order by id";
		$hope_work_location_list = $this->SysParams->generateList($condition11);
		$this->set("hope_work_location_list", $hope_work_location_list);
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/02/27
	 * update 2012/03/22
	* */
	function init_member_hope_worktype($op=null){
		$condition8 = "kbn = 'gyoshu_id' and deleted is null order by id";
		$exp_category_list = $this->SysParams->generateList($condition8);
		$this->set("exp_category_list", $exp_category_list);
		
		$condition9 = "kbn = 'shokusyu_id' and (pid in (1000,2000,3000,4000,5000,6000,7000,8000,9000) or id in (1000,2000,3000,4000,5000,6000,7000,8000,9000)) and deleted is null order by id";
		$exp_worktype_big_list = $this->SysParams->generateList($condition9);
		$this->set("exp_worktype_big_list", $exp_worktype_big_list);
		
		if($op=='toajax'){
			//add by wang.wei 2012/3/22
			$count = $this->params['url']['toid'] == '' ? 1 : '';
			$this->set("hope_worktype_small_list".$count, array());
		}
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/03/22
	* */
	function init_member_hope_category(){
		$condition8 = "kbn = 'gyoshu_id' and deleted is null order by id";
		$exp_category_list = $this->SysParams->generateList($condition8);
		$this->set("exp_category_list", $exp_category_list);
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/24
	* */
	function ajax_member_overseas_edu(){
		$condition = " kbn = 'country_id' and deleted is null";
		$country_list2 = $this->SysParams->generateList($condition,'sort');
		$this->set("country_list2", $country_list2);
		$this->init_member_overseas_edu();

	}
	
	/*
	 * @author wang.wei add
	* 2012/02/24
	* */
	function ajax_member_overseas_work(){
		$condition = " kbn = 'country_id' and deleted is null";
		$country_list2 = $this->SysParams->generateList($condition,'sort');
		$this->set("country_list2", $country_list2);
		$this->init_member_overseas_work();
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/02/27
	 * update 2012/03/9
	* */
	function ajax_member_lang(){
		$condition = " kbn='nationality_id' and deleted is null";
		$country_list = $this->SysParams->generateList($condition,'sort');
		$this->set("country_list", $country_list);
		$this->init_member_lang();
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/27
	* */
	function ajax_member_hope_work_location(){
		$this->init_member_hope_work_location();
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/27
	* */
	function ajax_member_hope_worktype(){
		$this->init_member_hope_worktype(toajax);
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/03/21
	* */
	function ajax_member_hope_category(){
		$this->init_member_hope_category();
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/02/28
	 * update 2012/3/22
	* */
	function ajax_hope_worktype_small($indexid) {
		$this->layout = 'ajax';
		$p = $this->data['Member']['hope_worktype'.$indexid.'_big'];
		//update by wang.wei 2012/3/22
		if(empty($p) || !$this->Valid->number($p)){
			$this->set("hope_worktype_small_list", array());
			$this->set("hope_worktype_indexid", $indexid);
		}else{
			$condition = " kbn ='shokusyu_id' and pid=" . $p;
			$hope_worktype_small_list = $this->SysParams->generateList($condition,
					'sort');
			$this->set("hope_worktype_small_list", $hope_worktype_small_list);
			$this->set("hope_worktype_indexid", $indexid);
		}
	}
	
	/*
	 * @author wang.wei add
	* 2012/3/3
	* */
	function memberdata_init($id,&$mem,$op) {
		
		// @author wang.wei 2012/3/15 add start
		$mem['Member']['work_visa_flg'] = $mem['Member']['work_visa_flg'] == '' ? 2 : $mem['Member']['work_visa_flg'];
		// @author wang.wei 2012/3/15 add end
		
		$me = $this->MemberEducation->find(
				"\"MemberEducation\".member_id=" . $id . " and \"MemberEducation\".deleted is null",
				"id,edu_degree",
				"order by \"MemberEducation\".id");
		if($op!='update'){
			$mem['MemberEducation']['edu_degree']=$me['MemberEducation']['edu_degree'];
			$mew = $this->Common->getMemberExpWorktypeDataByMemberid($id,
					null,
					"\"MemberExpWorktype\".id asc");
			for($i=0; $i<count($mew); $i++){
				$mem['MemberExpWorktype']['id'][$i]=$mew[$i]['MemberExpWorktype']['id'];
				$mem['MemberExpWorktype']['exp_category'][$i]=$mew[$i]['MemberExpWorktype']['exp_category'];
				$mem['MemberExpWorktype']['exp_worktype_big'][$i]=$mew[$i]['MemberExpWorktype']['exp_worktype_big'];
				$mem['MemberExpWorktype']['exp_worktype_small'][$i]=$mew[$i]['MemberExpWorktype']['exp_worktype_small'];
				$mem['MemberExpWorktype']['exp_year'][$i]=$mew[$i]['MemberExpWorktype']['exp_year'];
				
				if(!empty($mem['MemberExpWorktype']['exp_worktype_big'][$i]) 
						&& $this->Valid->number($mem['MemberExpWorktype']['exp_worktype_big'][$i])){
					$p = $mem['MemberExpWorktype']['exp_worktype_big'][$i];
					$condition = " kbn ='shokusyu_id' and pid=" . $p;
					$exp_worktype_small_list = $this->SysParams->generateList(
							$condition);
					$this->set("exp_worktype_small_list". $i, $exp_worktype_small_list);
					
				}else{
					//add by wang.wei 2012/3/22
					$this->set("exp_worktype_small_list". $i, array());
				}

			}
			
			/* add by wang.wei 2012/12/07 start */
			$mr = $this->Common->getMemberResumeDataByMemberid($id,
					'id,note',
					"\"MemberResume\".id asc");
			$mem['MemberResume']['id'] = $mr['MemberResume']['id'];
			$mem['MemberResume']['note'] = $mr['MemberResume']['note'];
			/* add by wang.wei 2012/12/07 end */
		}else{
			for($i=0; $i<count($mem['MemberExpWorktype']['exp_category']); $i++){
				if(!empty($mem['MemberExpWorktype']['exp_worktype_big'][$i])
					&& $this->Valid->number($mem['MemberExpWorktype']['exp_worktype_big'][$i])){
					
					$p = $mem['MemberExpWorktype']['exp_worktype_big'][$i];
					$condition = " kbn ='shokusyu_id' and pid=" . $p;
					$exp_worktype_small_list = $this->SysParams->generateList(
							$condition);
					$this->set("exp_worktype_small_list". $i, $exp_worktype_small_list);
					
				}else{
					$this->set("exp_worktype_small_list". $i, array());
				}
			}
		}

		$mem = $this->Common->checkMemberMultiLine($mem,$op);
		$mem['MemberEducation']['id']= $me['MemberEducation']['id'];
		$mem['Member']['member_overseas_edu_count']=$mem['DBM']['OE']['count'];
		$mem['Member']['member_overseas_work_count']=$mem['DBM']['OW']['count'];
		$mem['Member']['member_lang_count']=$mem['DBM']['Lang']['count'];
		$mem['Member']['member_hope_work_location_count']=$mem['DBM']['HWL']['count'];
		$mem['Member']['member_hope_worktype_count']=$mem['DBM']['HW']['count'];
		//@author wang.wei 2012/3/21 add
		$mem['Member']['member_hope_category_count']=$mem['DBM']['HC']['count'];

		//@author wang.wei 2012/3/9 update
		for($i=1; $i<=$mem['Member']['member_hope_worktype_count']; $i++){
			if(!empty($mem['DBM']['HW']['hope_worktype_big'][$i-1]) 
					&& $this->Valid->number($mem['DBM']['HW']['hope_worktype_big'][$i-1])){
				$p = $mem['DBM']['HW']['hope_worktype_big'][$i-1];
				$condition = " kbn ='shokusyu_id' and pid=" . $p;
				$hope_worktype_small_list = $this->SysParams->generateList(
						$condition);
				$this->set("hope_worktype_small_list". $i, $hope_worktype_small_list);
				
			}else{
				//add by wang.wei 2012/3/22
				$this->set("hope_worktype_small_list". $i, array());
			}
		}
		$this->init_reg3();
		$this->set("htmlValid",implode(',', $this->Member->htmlValid));

	}
	
	/*
	 * @author wang.wei add
	* 2012/3/3
	* */
// 	function memberdata_confirm(&$mem) {
// 		for($i = 0; $i < count($mem['MemberExpWorktype']['exp_category']); $i++) {
// 			if(!empty($mem['MemberExpWorktype']['exp_worktype_big'][$i])){
// 				$p = $mem['MemberExpWorktype']['exp_worktype_big'][$i];
// 				$condition = " kbn ='shokusyu_id' and pid=" . $p;
// 				$exp_worktype_small_list = $this->SysParams->generateList(
// 						$condition);
// 				$this->set("exp_worktype_small_list". $i, $exp_worktype_small_list);
// 			}else{
// 				//add by wang.wei 2012/3/22
// 				$this->set("exp_worktype_small_list". $i, array());
// 			}
// 		}
		
// 		for($i = 1; $i <= $mem['Member']['member_hope_worktype_count']; $i++) {
// 			if(!empty($mem['Member']['hope_worktype'.$i.'_big'])){
// 				$p = $mem['Member']['hope_worktype'.$i.'_big'];
// 				$condition = " kbn ='shokusyu_id' and pid=" . $p;
// 				$hope_worktype_small_list = $this->SysParams->generateList(
// 						$condition);
// 				$this->set("hope_worktype_small_list". $i, $hope_worktype_small_list);
// 			}else{
// 				//add by wang.wei 2012/3/22
// 				$this->set("hope_worktype_small_list". $i, array());
// 			}
// 		}
// 		$this->init_reg3();
// 		$this->set("htmlValid",implode(',', $this->Member->htmlValid));

// 	}
	
	/*
	 * @author wang.wei 
	 * add 2012/3/7
	 * update 2012/3/21
	* */
	function memberdata_beforeConfirm(&$mem) {
		for($op = 1; $op<=6; $op++){
			$this->memberdata_beforeToConfirm($op, $mem);
		}
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/3/7
	 * update 2012/3/21
	* */
	function memberdata_beforeToConfirm($op,&$mem) {
		$count=0;
		switch ($op){
			case 1:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['overseas_edu'.$i.'_nation'])){
						$mem['Member']['overseas_edu'.$i.'_nation']='';
						$mem['Member']['overseas_edu'.$i.'_period']='';
						$mem['Member']['overseas_edu'.$i.'_purpose']='';
					}else{
						$count++;
					}
				}
				$mem['Member']['member_overseas_edu_count']=$count;
				break;
			case 2:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['overseas_work'.$i.'_nation'])){
						$mem['Member']['overseas_work'.$i.'_nation']='';
						$mem['Member']['overseas_work'.$i.'_period']='';
						$mem['Member']['overseas_work'.$i.'_position']='';
					}else{
						$count++;
					}
				}
				$mem['Member']['member_overseas_work_count']=$count;
				break;
			case 3:
				//@author wang.wei 2012/3/9 update
	
				//@author wang.wei 2012/3/19 update start
				for($i = 1; $i<=5; $i++){
					if(empty($mem['Member']['foreign_lang'.$i])){
						if($i==1){
							$mem['Member']['foreign_lang'.$i] = '';
							$mem['Member']['foreign_lang_level'.$i] = '';
						}elseif($i==2){
							$mem['Member']['foreign_lang'.$i] = '';
							$mem['Member']['foreign_lang_level'.$i] = '';
						}elseif($i==3){
							$mem['Member']['foreign_lang'.$i] = '';
							$mem['Member']['foreign_lang_level'.$i] = '';
						}elseif($i==4){
							$mem['Member']['foreign_lang'.$i] = '';
							$mem['Member']['foreign_lang_level'.$i] = '';
						}elseif($i==5){
							$mem['Member']['foreign_lang'.$i] = '';
							$mem['Member']['foreign_lang_level'.$i] = '';
						}
					}else{
						$count++;
					}
				}
				//@author wang.wei 2012/3/19 update end
				$mem['Member']['member_lang_count']=$count;
				break;
			case 4:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_work_location'.$i])){
						$mem['Member']['hope_work_location'.$i]='';
					}else{
						$count++;
					}
				}
				$mem['Member']['member_hope_work_location_count']=$count;
				break;
			case 5:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_category'.$i])){
						$mem['Member']['hope_category'.$i]='';
					}else{
						$count++;
					}
				}
				$mem['Member']['member_hope_category_count']=$count;
				break;
			case 6:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_worktype'.$i.'_big'])){
						$mem['Member']['hope_worktype'.$i.'_big']='';
						$mem['Member']['hope_worktype'.$i.'_small']='';
					}else{
						$count++;
					}
				}
				$mem['Member']['member_hope_worktype_count']=$count;
				break;
		}
	
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/3/7
	 * update 2012/3/21
	* */
	function memberdata_beforeSave(&$mem) {
		for($op = 1; $op<=6; $op++){
			$this->memberdata_beforeToSave($op, $mem);
		}
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/3/7
	 * update 2012/3/21
	* */
	function memberdata_beforeToSave($op,&$mem) {
		$count=1;
		switch ($op){
			case 1:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['overseas_edu'.$i.'_nation'])){
						$mem['Member']['overseas_edu'.$i.'_nation']='';
						$mem['Member']['overseas_edu'.$i.'_period']='';
						$mem['Member']['overseas_edu'.$i.'_purpose']='';
					}else{
						$mem['Member']['overseas_edu'.$count.'_nation']=$mem['Member']['overseas_edu'.$i.'_nation'];
						$mem['Member']['overseas_edu'.$count.'_period']=$mem['Member']['overseas_edu'.$i.'_period'];
						$mem['Member']['overseas_edu'.$count.'_purpose']=$mem['Member']['overseas_edu'.$i.'_purpose'];
						$count++;
					}
				}
				$mem['Member']['member_overseas_edu_count']=$count-1;
				break;
			case 2:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['overseas_work'.$i.'_nation'])){
						$mem['Member']['overseas_work'.$i.'_nation']='';
						$mem['Member']['overseas_work'.$i.'_period']='';
						$mem['Member']['overseas_work'.$i.'_position']='';
					}else{
						$mem['Member']['overseas_work'.$count.'_nation']=$mem['Member']['overseas_work'.$i.'_nation'];
						$mem['Member']['overseas_work'.$count.'_period']=$mem['Member']['overseas_work'.$i.'_period'];
						$mem['Member']['overseas_work'.$count.'_position']=$mem['Member']['overseas_work'.$i.'_position'];
						$count++;
					}
				}
				$mem['Member']['member_overseas_work_count']=$count-1;
				break;
			case 3:
				//@author wang.wei 2012/3/19 update start
				for($i = 1; $i<=5; $i++){
					if(empty($mem['Member']['foreign_lang'.$i])){
						unset($mem['Member']['foreign_lang'.$i]);
						unset($mem['Member']['foreign_lang_level'.$i]);
					}else{
						$mem['Member']['foreign_lang'.$count]=$mem['Member']['foreign_lang'.$i];
						$mem['Member']['foreign_lang_level'.$count]=$mem['Member']['foreign_lang_level'.$i];
						$count++;
					}
				}
				//@author wang.wei 2012/3/19 update end
				
				$mem['Member']['member_lang_count']=$count-1;
				break;
			case 4:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_work_location'.$i])){
						$mem['Member']['hope_work_location'.$i]='';
					}else{
						$mem['Member']['hope_work_location'.$count]=$mem['Member']['hope_work_location'.$i];
						$count++;
					}
				}
				$mem['Member']['member_hope_work_location_count']=$count-1;
				break;
			case 5:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_category'.$i])){
						$mem['Member']['hope_category'.$i]='';
					}else{
						$mem['Member']['hope_category'.$count]=$mem['Member']['hope_category'.$i];
						$count++;
					}
				}
				$mem['Member']['member_hope_category_count']=$count-1;
				break;
			case 6:
				for($i = 1; $i<=3; $i++){
					if(empty($mem['Member']['hope_worktype'.$i.'_big'])){
						$mem['Member']['hope_worktype'.$i.'_big']='';
						$mem['Member']['hope_worktype'.$i.'_small']='';
					}else{
						$mem['Member']['hope_worktype'.$count.'_big']=$mem['Member']['hope_worktype'.$i.'_big'];
						$mem['Member']['hope_worktype'.$count.'_small']=$mem['Member']['hope_worktype'.$i.'_small'];
						$count++;
					}
				}
				$mem['Member']['member_hope_worktype_count']=$count-1;
				break;
		}
	
	}
	
	
	/*
	 * @author wang.wei add
	* 2012/3/3
	* */
	function memberdata_save(&$mem,$op) {

		$saveFlg = true;
		if($mem['Member']['work_visa_flg']=='1'){
			$mem['Member']['work_visa_nation']='';
		}
		if($mem['Member']['hope_income_flg']=='1'){
			$mem['Member']['hope_income']='';
			$mem['Member']['hope_income_to']='';
			$mem['Member']['hope_income_cur']='';
		}
		if($mem['Member']['hope_work_location_flg']=='1'){
			$mem['Member']['hope_work_location1']='';
			$mem['Member']['hope_work_location2']='';
			$mem['Member']['hope_work_location3']='';
		}
		
		// @author wang.wei 2012/3/21 add start
		if($mem['Member']['hope_category_flg']=='1'){
			$mem['Member']['hope_category1']='';
			$mem['Member']['hope_category2']='';
			$mem['Member']['hope_category3']='';
		}
		if($mem['Member']['hope_worktype_flg']=='1'){
			$mem['Member']['hope_worktype1_big']='';
			$mem['Member']['hope_worktype1_small']='';
			$mem['Member']['hope_worktype2_big']='';
			$mem['Member']['hope_worktype2_small']='';
			$mem['Member']['hope_worktype3_big']='';
			$mem['Member']['hope_worktype3_small']='';
		}
		// @author wang.wei 2012/3/21 add end
		// @author wang.wei 2012/4/12 add start
//		if($this->Session->read("public_profile_flg".$mem['Member']['id'])){
		if($this->Session->check("public_profile_flg".$mem['Member']['id']) ||
				($this->Session->read("public_profile_flg".$mem['Member']['id']) != $mem['Member']['public_profile_flg'])){
			$mem['Member']['public_profile_flg_updated'] = date('Y-m-d H:i:s');
		}
//		}
		$this->Session->del("public_profile_flg".$mem['Member']['id']);
		
		// @author wang.wei 2012/5/17 add
		if($op=='insert'){
			$mem['Member']['created']=date('Y-m-d H:i:s');
		}
		
		if($op=='update'){
			unset($mem['Member']['login_id']);
			unset($mem['Member']['created']);
		}
		
		// @author wang.wei 2012/4/12 add end
		$saveFlg = $this->Member->save($mem['Member']);
		if($op=='update'){
			$mem['Member']['login_id'] = $this->rdAuth->login_id;
		}
		
		$MemberEducation = array();
		if($op=='update'){
			$this->MemberExpWorktype->doDeleteFormMemberId($mem['Member']['id']);
			$MemberEducation['id']=$mem['MemberEducation']['id'];
		}
		
		$MemberExpWorktype = array();
		for($i = 0; $i < count($mem['MemberExpWorktype']['exp_category']); $i++) {
			/* if(!empty($mem['MemberExpWorktype']['id'][$i])){
				$MemberExpWorktype['id'] = $mem['MemberExpWorktype']['id'][$i];
			} */
			$MemberExpWorktype['member_id'] = $mem['Member']['id'];
			$MemberExpWorktype['exp_category'] = $mem['MemberExpWorktype']['exp_category'][$i];
			$MemberExpWorktype['exp_worktype_big'] = $mem['MemberExpWorktype']['exp_worktype_big'][$i];
			$MemberExpWorktype['exp_worktype_small'] = $mem['MemberExpWorktype']['exp_worktype_small'][$i];
			$MemberExpWorktype['exp_year'] = $mem['MemberExpWorktype']['exp_year'][$i];
			$this->MemberExpWorktype->create();
			if ($saveFlg) {
				$saveFlg = $this->MemberExpWorktype->save($MemberExpWorktype);
			} else {
				return $saveFlg;
			}

		}
		$MemberEducation['edu_degree'] = $mem['MemberEducation']['edu_degree'];
		$MemberEducation['member_id'] = $mem['Member']['id'];
		//$this->MemberEducation->create();
		if ($saveFlg) {
			$this->MemberEducation->save($MemberEducation);
		} else {
			return $saveFlg;
		}
		
		/* add by wang.wei 2012/12/07 start */
		$MemberResume = array();
		if($op == 'update'){
			$MemberResume['id'] = $mem['MemberResume']['id'];
		}
		$MemberResume['member_id'] = $mem['Member']['id'];
		$MemberResume['note'] = $mem['MemberResume']['note'];
		$MemberResume['note_length'] = $mem['MemberResume']['note_length'];
		if ($saveFlg) {
			$this->MemberResume->save($MemberResume);
		} else {
			return $saveFlg;
		}
		/* add by wang.wei 2012/12/07 end */
		
		$this->Common->updateMemberInfoAndMemberResumePoint($mem['Member']['id']);
		
		// wang.wei add 2012/4/7 start
		$this->updateLastPwdDate($mem['Member']['login_pwd'], $mem['Member']['id']);
		// wang.wei add 2012/4/7 end

		//nan Enhance 2013/1/7 start
		if ($op=='update' && $saveFlg) {
			$saveFlg = $this->SpecialPublicInfo->doSaveSpecialCompany($mem['Member']['public_profile_flg'], $mem['special'], $mem['Member']['id']);
		}
		//nan Enhance 2013/1/7 end

		return $saveFlg;
		
	}
	//@author zhufeng
	function confirmMem() {
		
		// add エラー対策(F7) tsubasa 2012/11/13 start;
		
		if($this->isCountError($this->data['Member'])) {
			$this->show404();
			exit;
		}
		
		// add エラー対策(F7) tsubasa 2012/11/13 end;
		
		// wang.wei add 2012/5/23 start
		$this->Output->htmlspecialchars($this->data);
		// wang.wei add 2012/5/23 end
		
		$member = $this->data;
		
		$me = $this->Session->read("myMember");
		$id = $me['Member']['id'];
		if (empty($id) || $id == null) {
			$this->showError('session_expired');
		}
		$p = $this->data['Member']['agree'];
			
		$y = $this->data['Birthday']['yyyy'];
		//			$m=$this->data['Birthday']['mm'];
		//			$d=$this->data['Birthday']['dd'];
		$m = (strlen($this->data['Birthday']['mm']) > 1) ? $this->data['Birthday']['mm'] : '0' . $this->data['Birthday']['mm'];
		$d = (strlen($this->data['Birthday']['dd']) > 1) ? $this->data['Birthday']['dd'] : '0' . $this->data['Birthday']['dd'];
		//pr($this->data['Birthday']['yyyy']);
		$this->data['Member']['birthday'] = $y . "-" . $m . "-" . $d;
		//pr($this->data['Member']['birthday']);
		// @author wang.wei 2012/3/15 add start
		$this->data['Member']['hope_income']=str_replace(',','',$this->data['Member']['hope_income']);
		$this->data['Member']['hope_income_to']=str_replace(',','',$this->data['Member']['hope_income_to']);
		// @author wang.wei 2012/3/15 add end
		$message = $this->Member->RegValid($this->Valid, 
			$this->data);

		if ($this->data['Member']['login_id'] == $this->data['Member']['login_pwd'] && $this->data['Member']['login_pwd'] != null) {
			$message .= $this->Valid->tagErrorMsg('reg_pwd_repeat', 
				'Member/login_pwd');
		}
		
		if (empty($message)) {
			$this->data['Member']['id'] = $me['Member']['id'];
			$mem = $this->data;
			$myMem = $this->Member->find(
					"\"Member\".id=" . $id . " and \"Member\".deleted is null");
			
			// @author wang.wei 2012/2/27 edit
			$mem['Member']['email'] = $myMem['Member']['email'];
			
			$mem['Member']['created'] = $myMem['Member']['created'];
						
			$this->Session->write("myMember", $mem);
			$mem = $this->setMem($mem);
// 			if (isset($mem['Member']['grad_date']) && empty(
// 				$mem['Member']['grad_date'])) {
// 				unset($mem['Member']['grad_date']);
// 			}

			//$this->Session->write("myMember", $mem);
			$this->set("myMember", $mem);
			$this->pageTitle = "カモメ会員登録";
			$this->render('reg4');
			
			exit();
		} else {
			
			$this->data['Member']['id'] = $id;
			$mem = $this->data;
			$myMember = $this->Session->read("myMember");
			$mem['Member']['email'] = $myMember['Member']['email'];
			$created = $myMember['Member']['created'];
			
			$mem['Member']['created'] = $myMember['Member']['created'];
			
			$condition = " kbn='nationality_id' and deleted is null";
			
			$country_list = $this->SysParams->generateList($condition, 
				'sort');
			$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
			
			$pid = $this->data['Member']['address_nation_id'];
			
			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid . "  and deleted is null";
				
				$city_list = $this->SysParams->generateList($condition2, 'sort');
				
				$this->set("city_list", $city_list);
			}
			
			
			// @author wang.wei 2012/3/3 add start
			//$this->memberdata_confirm($mem);
			$this->memberdata_init($id,$mem,'update');
			// @author wang.wei 2012/3/3 add end
			
			$this->myInit();
			$this->set("myMember", $mem);
			$this->data = $mem;
			$this->set("message", $message);
			$this->pageTitle = "カモメ会員登録";
			
			$this->render('reg3');
			
			exit();
		}

	}
	function confirmMem2() {
		$mem = $this->Session->read("myMember");
		if (empty($mem['Member']['id']) || $mem['Member']['id'] == null) {
			$this->showError('session_expired');
		}
		$myMember = $this->Member->find(
			"\"Member\".id=" . $mem['Member']['id'] . " and \"Member\".deleted is null");
		$mem['Member']['email'] = $myMember['Member']['email'];
		$mem['Member']['id'] = $myMember['Member']['id'];
		$mem['Member']['created'] = $myMember['Member']['created'];
		
		$condition = " kbn='nationality_id' and deleted is null";
		
		$country_list = $this->SysParams->generateList($condition, 'sort');
		$country_list2 = $this->SysParams->generateList(
			"kbn = 'country_id' and deleted is null",'sort');
		$this->set("country_list", $country_list);
		$this->set("country_list2", $country_list2);
		
		$pid = $mem['Member']['address_nation_id'];
		
		if ($this->Valid->number($pid)) {
			$condition2 = " kbn ='city_id' and pid=" . $pid . "  and deleted is null";
			$city_list = $this->SysParams->generateList($condition2, 'sort');
			$this->set("city_list", $city_list);
		}
		
		// @author wang.wei 2012/3/3 add start
		//$this->memberdata_confirm($mem);
		$this->memberdata_init($mem['Member']['id'],$mem,'update');
		// @author wang.wei 2012/3/3 add end
		
		$this->myInit();
		$this->set("myMember", $mem);
		
		$this->data = $mem;
		$this->pageTitle = "カモメ会員登録";
		$this->render('reg3');
	}

	//@author zhufeng
	function reg5() {
		
		$this->pageTitle = "カモメ会員登録";
		if (!$this->Session->check('myMember')) {
			$this->showError('session_expired');
		}
		$mem = $this->Session->read("myMember");
		if (empty($mem['Member']['id']) || $mem['Member']['id'] == null || empty($mem['Member']['login_id'])) {
			$this->showError('session_expired');
		}
		$mem['Member']['member_role'] = 'member';
		$mem['Member']['login_pwd'] = Md5($mem['Member']['login_pwd']);
// 		if (isset($mem['Member']['grad_date']) && empty(
// 			$mem['Member']['grad_date'])) {
// 			unset($mem['Member']['grad_date']);
// 		}
		
		$this->Member->db->begin($this->Member);
		
		// @author wang.wei 2012/3/3 add start
		if (!$this->memberdata_save($mem,'insert')){
			$this->Member->db->rollback($this->Member);//die("@@sd@@");
			$this->show404();
			exit;
		}

		//$this->rdAuth->set($mem['Member']);
		$info = array();
		$info['Member']['id'] = $mem['Member']['id'];
		$info['Member']['last_login_data']=date("Y-m-d H:i:s");
		$this->Member->updateLastLogin($info);
		// @author wang.wei 2012/3/3 add end
		
		$mem2 = $this->Member->find(
			"Member.id=" . $mem['Member']['id'] . " and Member.deleted is null");
		$this->rdAuth->set($mem2['Member']);
		$subject2 = $this->Prop->getValue(
			'config.mail_title.member_regist_finish');
		$data2['name'] = $mem['Member']['name_kanji'];
		$data2['url'] = "memberLogin/login/member/remmember";
		$contents2 = $this->getMailTemplate("member_regist_finish", $data2);
		$this->MailJob->saveMsg('web@localhost:82', $mem['Member']['email'], 
			$subject2, $contents2, "", 'info@localhost:82');
		if ($_SESSION['yyyy'] != null) {
			$_SESSION['yyyy'] = null;
		}
		if ($_SESSION['mm'] != null) {
			$_SESSION['mm'] = null;
		}

		$this->Member->db->commit($this->Member);
		
		$this->Session->del("myMember");
		
		$this->render("reg5");
		exit();
	}
	
	//@author zhufeng
	function remainpwd1() {

	}
	
	function send_pwd_success() {}
	//@author zhufeng
	function remainPwd() {
		$email = $this->data['Member']['email'];
		$message = '';
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/email', 
			'required');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/email', 'email');
		
		if (empty($message)) {
			$this->Encrypt->encode($email);
			$member = $this->Member->find(
					"\"Member\".email='" . $email . "' and \"Member\".deleted is null" . " AND \"Member\".member_role = 'member'");
			
			if (empty($member)) {
				$message .= $this->Valid->tagErrorMsg('not_exist', 
					'Member/email');
				$this->set("message", $message);
				$this->render('remainpwd1');
				exit();
			}
			$this->set("myMember", $member);
			
			//20081229
			$this->Member->belongsTo = array();
			//$member = $this->Member->find("\"Member\".email='$email'");
			$remained_key = $this->Encrypt->randKey('6');
			$data['url'] = 'http://' . $_SERVER['SERVER_NAME'] . "/member/remainpwd2/" . Md5(
				$remained_key) . $member['Member']['id'];
			$data['name'] = $member['Member']['name_kanji'];
			$contents = $this->getMailTemplate("pwd_confirm", $data);
			$subject = $this->Prop->getValue('config.mail_title.pwd_confirm');
			$this->MailJob->saveMsg('web@localhost:82', 
				$this->data['Member']['email'], $subject, $contents, "", 
				'info@localhost:82');
			
			$remain_timeout = $this->Prop->getValue(
				"config.remain_timeout_hour");
			$remained = mktime(date('H') + $remain_timeout, date('i'), 
				date('s'), date('m'), date('d'), date('Y'));
			
			$member['Member']['remained'] = date("Y-m-d H:i:s", $remained);
			$member['Member']['remain_key'] = $remained_key;
			
			$this->Member->saveremain($member);
			
			$this->render('send_pwd_success');
			//			$this->render('remainpwd2');
			exit();
		} else {
			$this->set("message", $message);
			$this->render('remainpwd1');
			exit();
		}
	}
	
	//@author zhufeng
	function remainpwd2($str) {
		$member_id = substr($str, 32);
		
		if (!$this->Valid->number($member_id)) {
			$this->show404();
			exit;
		}
		
		$key = substr($str, 0, 32);
		$member = $this->Member->find("\"Member\".id = $member_id ");
		if (md5($member['Member']['remain_key']) != $key) {
			$this->showError('password_remain_key_error');
		}
		
		if (date("Y-m-d H:i:s") > $member['Member']['remained']) {
			$this->showError('password_remain_key_timeout');
		}
		$this->set('myMember', $member);
		$this->render();
	
	}
	//@author zhufeng
	function remainpwd3() {

	}
	
	//@author zhufeng
	function rempwd() {
		$answer = $this->data['Member']['pwd_remain_answer'];
		$id = $this->data['Member']['id'];
		
		if (!$this->Valid->number($id)) {
			$this->show404();
			exit;
		}	
		
		$member = $this->Member->find(
			"\"Member\".id=" . $id . " and \"Member\".deleted is null");
		if ($answer != $member['Member']['pwd_remain_answer']) {
			$message = "答えは間違っています";
			$this->set("myMember", $member);
			$this->set("message", $message);
			$this->set("data", $this->data);
			$this->render('remainpwd2');
			exit();
		} else {
			$this->set("myMember", $member);
			$this->render('remainpwd3');
			exit();
		}
	}
	
	//@author zhufeng
	function remainpwd5() {

	}
	
	//@author zhufeng
	function remainMyPwd2() {
		$id = $this->data['Member']['id'];
		if (!$this->Valid->number($id)) {
			$this->show404();
			exit;
		}
		
		$member = $this->Member->find(
			"\"Member\".id=" . $id . " and \"Member\".deleted is null");
		$password = $this->params['form']['data']['Member']['login_pwd'];
		$message = '';
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/login_pwd', 
			'required');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/login_pwd', 
			'confirm');
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/login_pwd', 
			'minmaxlength', '6-20');
		
		//wang.wei 2012/4/8 add start
		$message .= $this->Valid->ErrorMsg($this->data, 'Member/login_pwd', 'password_input_member');
		//wang.wei 2012/4/8 add end
		
		if ($member['Member']['login_id'] == $this->data['Member']['login_pwd'] && $this->data['Member']['login_pwd'] != null) {
			$message .= $this->Valid->tagErrorMsg('reg_pwd_repeat', 
				'Member/login_pwd');
		
		}
		if (empty($message)) {
			$member['Member']['login_pwd'] = $password;
			$this->Member->savePassword($password, $id);
			// wang.wei add 2012/4/8 start
			$this->updateLastPwdDate($password, $this->data['Member']['id']);
			// wang.wei add 2012/4/8 end
			$data['name'] = $member['Member']['name_kanji'];
			$data['email'] = $member['Member']['email'];
			$contents = $this->getMailTemplate("pwd_find_finish", $data);
			$subject = $this->Prop->getValue('config.mail_title.pwd_find');
			$this->MailJob->saveMsg('web@localhost:82', $data['email'], $subject, 
				$contents, "", 'info@localhost:82');
			
			$this->render('remainpwdfinish');
			exit();
		} else {
			$this->set("message", $message);
			$this->set("myMember", $member);
			$this->render('remainpwd3');
			exit();
		}
	}

	
	
	function remmember2($id = null) {
		
		// @author wang.wei 2012/2/29 add start
		$return_id = $id;
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		
		// @author wang.wei 2012/2/29 add end
		if ($return_id == 'back' && $this->Session->check('myMember')) {
			$mem = $this->Session->read("myMember");
			// @author wang.wei 2012/3/3 add start
			$this->memberdata_init($id,$mem,'update');
			// @author wang.wei 2012/3/3 add end
			//$this->params['data'] = $mem;
			//print_r($mem);
			$this->set("myMember", $mem);
			$this->myInit();
			$condition = " kbn='nationality_id' and deleted is null";
			$country_list = $this->SysParams->generateList($condition, 'sort');
			$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
			
			$pid = $mem['Member']['address_nation_id'];
			
			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid;
				
				$city_list = $this->SysParams->generateList($condition2);
				
				$this->set("city_list", $city_list);
			}			
			$this->render('remmember2');
			
			exit();
		
		}
		$mem = $this->Member->find(
			"\"Member\".id=" . $id . " and \"Member\".deleted is null");
		// @author wang.wei 2012/4/12 add start
		$this->Session->del("public_profile_flg".$id);
		$this->Session->write("public_profile_flg".$id,$mem['Member']['public_profile_flg']);
		// @author wang.wei 2012/4/12 add end
		// @author wang.wei 2012/3/3 add start
		$this->memberdata_init($id,$mem,'insert');
		// @author wang.wei 2012/3/3 add end
		$birthday = $mem['Member']['birthday'];
		$delete = array();
		$delete = split('-', $birthday);
		$mem['Birthday']['yyyy'] = $delete[0];
		$mem['Birthday']['mm'] = $delete[1];
		$mem['Birthday']['dd'] = $delete[2];
		$condition = " kbn='nationality_id' and deleted is null";
		
		$country_list = $this->SysParams->generateList($condition, 'sort');
		$country_list2 = $this->SysParams->generateList(
			"kbn = 'country_id' and deleted is null",'sort');
		$this->set("country_list", $country_list);
		$this->set("country_list2", $country_list2);
		
		$pid = $mem['Member']['address_nation_id'];
		
		if ($this->Valid->number($pid)) {
			$condition2 = " kbn ='city_id' and pid=" . $pid . " and deleted is null";
			
			$city_list = $this->SysParams->generateList($condition2);
			
			$this->set("city_list", $city_list);
		}
		$this->myInit();
		
		//nan 2013/1/5 Enhance対応  特別公開の修正 start
		$special = $this->SpecialPublicInfo->getSpecialCompanyByMemberID($id);
		$mem = array_merge($mem, $special);
		//nan 2013/1/5 Enhance対応  特別公開の修正 end		
		
		$this->data = $mem;
		$this->set("myMember", $mem);
		$this->render('remmember2');
	
	}
	function myInit() {
		$condition3 = "kbn = 'interest_work_type_id' and deleted is null";
		$work_list = $this->SysParams->generateList($condition3);
		$this->set("work_list", $work_list);
		$condition4 = "kbn = 'education_id' and deleted is null";
		$education_list = $this->SysParams->generateList($condition4);
		$this->set("education_list", $education_list);
		$condition5 = "kbn='work_status_id' and deleted is null";
		$work_status = $this->SysParams->generateList($condition5);
		$this->set("work_status", $work_status);
		$condition6 = "kbn='sex_id' and deleted is null";
		$sex_list = $this->SysParams->generateList($condition6);
		$this->set("sex_list", $sex_list);
		$condition7 = "kbn='language_id' and deleted is null ";
		$language_list = $this->SysParams->generateList($condition7);
		$this->set("language_list", $language_list);
		$condition8 = "kbn='password_question_id' and deleted is null";
		$pwd_list = $this->SysParams->generateList($condition8);
		$this->set("pwd_list", $pwd_list);
		$y = date('Y');
		$yearlist = array();
		
		for($i = 1936; $i <= $y; $i++) {
			$yearlist[$i] = $i;
		
		}
		$this->set("yearlist", $yearlist);
		$monthlist = array();
		
		for($i = 1; $i <= 12; $i++) {
			$monthlist[$i] = $i;
		
		}
		$this->set("monthlist", $monthlist);
		$daylist = array();
		
		for($i = 1; $i <= 31; $i++) {
			$daylist[$i] = $i;
		
		}
		$this->set("daylist", $daylist);
	
	}
	//@author zhufeng
	function remMyMember($id = null) {
		
		$id = $this->rdAuth->id;
		// @author wang.wei 2012/2/29 add start
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		// wang.wei add 2012/5/23 start
		$this->Output->htmlspecialchars($this->data);
		// wang.wei add 2012/5/23 end
		
		// @author wang.wei 2012/2/29 add end
		$y = $this->data['Birthday']['yyyy'];
		$m = (strlen($this->data['Birthday']['mm']) > 1) ? $this->data['Birthday']['mm'] : '0' . $this->data['Birthday']['mm'];
		$d = (strlen($this->data['Birthday']['dd']) > 1) ? $this->data['Birthday']['dd'] : '0' . $this->data['Birthday']['dd'];
		//pr($this->data['Birthday']['yyyy']);
		$this->data['Member']['birthday'] = $y . "-" . $m . "-" . $d;
		//pr($this->data['Member']['birthday']);
		$message = '';
		// @author wang.wei 2012/3/15 add start
		$mem = $this->data;
		// add エラー対策(F7) tsubasa 2012/11/13 start;
		/* wang.wei 2013/1/09 add start */
		unset($mem['special']['special_del']);
		/* wang.wei 2013/1/09 add end */
		if($this->isCountError($mem['Member'])) {
			$this->show404();
			exit;
		}
		
		// add エラー対策(F7) tsubasa 2012/11/13 end;
		
		$mem['Member']['hope_income']=str_replace(',','',$mem['Member']['hope_income']);
		/* wang.wei 2012/12/10 add start */
		$mem['Member']['hope_income_to']=str_replace(',','',$mem['Member']['hope_income_to']);
		/* wang.wei 2012/12/10 add end */
		// @author wang.wei 2012/3/15 add end
		$message = $this->Member->memValid($this->Valid, $mem);
		$message .= $this->Member->emailValid($this->Valid, $mem);
		// wang.wei add 2012/4/7 start
		$message .=$this->checkUpdateTheSamePwd($this->data['Member']['login_pwd'], $this->data['Member']['id']);
		// wang.wei add 2012/4/7 end
		
		if ($this->rdAuth->login_id == $this->data['Member']['login_pwd'] && $this->data['Member']['login_pwd'] != null) {
			$message .= $this->Valid->tagErrorMsg('reg_pwd_repeat', 
				'Member/login_pwd');
		}
		if (empty($message)) {
			$mem['Member']['id'] = $this->rdAuth->id;
			$myMem = $this->Member->find(
				"\"Member\".id=" . $id . " and \"Member\".deleted is null");
			//by20081217 email可以修改
			//			$mem['Member']['email']=$myMem['Member']['email'];
			$mem['Member']['login_id'] = $myMem['Member']['login_id'];
			$mem['Member']['created'] = $myMem['Member']['created'];
/* 			//@author wangyuhua 2012/3/15
			if($mem['Member']['hope_income_flg'] == 2) {
				$this->setIncome($mem['Member']['hope_income'], $mem['Member']['hope_income_cur'] ); 
			} else {
				$mem['Member']['hope_income'] = '希望なし';
			} */
			// @author wang.wei 2012/3/16 add start
			$this->memberdata_beforeConfirm($mem);
			// @author wang.wei 2012/3/16 add end
			$this->Session->write("myMember", $mem);
			// @author wang.wei 2012/3/7 add start
			$this->memberdata_beforeSave($mem);
			// @author wang.wei 2012/3/7 add end
//print_r($mem['special']);exit;
			$mem = $this->setMem($mem);
			$this->set("myMember", $mem);
			$this->render("remmember4");
			exit();
		} else {
			//$mem = $this->setMem($this->data);
			$myMember = $this->Member->find(
				"\"Member\".id=" . $id . " and \"Member\".deleted is null");
			//$mem['Member']['email'] = $myMember['Member']['email'];
			
			/* //@author wangyuhua 2012/3/15
			if($myMember['Member']['hope_income_flg'] == 2) {
				$this->setIncome($myMember['Member']['hope_income'], $myMember['Member']['hope_income_cur'] );
			} else {
				$myMember['Member']['hope_income'] = '希望なし';
			} */
			$created = $myMember['Member']['created'];
			$mem['Member']['id'] = $this->rdAuth->id;
			$mem['Member']['login_id'] = $myMember['Member']['login_id'];
			$mem['Member']['created'] = $myMember['Member']['created'];
			$condition = " kbn='nationality_id' and deleted is null";
			
			$country_list = $this->SysParams->generateList($condition, 'sort');
			$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
			
			$pid = $this->data['Member']['address_nation_id'];
			
			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid . " and deleted is null";
				$city_list = $this->SysParams->generateList($condition2);
				$this->set("city_list", $city_list);
			}
			
			// @author wang.wei 2012/3/3 add start 
			//update 2012/4/5 
			//$this->memberdata_confirm($mem);
			$this->memberdata_init($id,$mem,'update');
			// @author wang.wei 2012/3/3 add end
			$this->myInit();
			$this->set("myMember", $mem);
			$this->set("message", $message);
			
			$this->render('remmember2');
			exit();
		}
	}
	
	//@author zhufeng
	function remmember3() {

	}
	//@author zhufeng
	function remmember4() {

	}
	//@author zhufeng
	function remmember6() {
		
		// @author wang.wei 2012/3/1 add start
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		// @author wang.wei 2012/3/1 add end
		
		$mem = $this->Session->read("myMember");
		if (isset($mem['Member']['login_pwd'])) {
			$mem['Member']['login_pwd'] = trim($mem['Member']['login_pwd']);
			if (!empty($mem['Member']['login_pwd'])) {
				//echo 'yangjie>>>>>>>>';
				$mem['Member']['login_pwd'] = Md5($mem['Member']['login_pwd']);
			} else {
				unset($mem['Member']['login_pwd']);
			}
		}
		
		if ($this->Session->check('myMember')) {
			// @author wang.wei 2012/3/3 add start
			$this->memberdata_save($mem,'update');
			// @author wang.wei 2012/3/3 add end
		}
		
		$this->Session->del('myMember');
		$this->rdAuth->set($mem['Member']);
		if ($_SESSION['yyyy'] != null) {
			$_SESSION['yyyy'] = null;
		}
		if ($_SESSION['mm'] != null) {
			$_SESSION['mm'] = null;
		}
	}
	//@author zhufeng revise member_info and finally redirect search order_input
	function reviseMember($id = null,$backid = null) {
		
		$id1 = $this->rdAuth->id;
		// @author wang.wei 2012/3/5 add start
		if (empty($id1)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		// @author wang.wei 2012/3/5 add end
		
		// @author wang.wei 2012/3/13 add start
		if ($backid == 'back' && $this->Session->check('myMember')) {
			$mem = $this->Session->read("myMember");
			// @author wang.wei 2012/3/3 add start
			$this->memberdata_init($id,$mem,'update');
			// @author wang.wei 2012/3/3 add end
			//$this->params['data'] = $mem;
			//print_r($mem);
			$this->set("myMember", $mem);
			$this->myInit();
			$condition = " kbn='nationality_id' and deleted is null";
			$country_list = $this->SysParams->generateList($condition, 'sort');
			$country_list2 = $this->SysParams->generateList(
					"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
		
			$pid = $mem['Member']['address_nation_id'];			
			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid . " and deleted is null";
				$city_list = $this->SysParams->generateList($condition2);
				$this->set("city_list", $city_list);
			}
			
			$this->set("job_id", $id);
			$this->render('revisemem');
		
			exit();
		
		}
		// @author wang.wei 2012/3/13 add end
		
		if (!empty($id1)) {
			$mem = $this->Member->find(
				"\"Member\".id=" . $id1 . " and \"Member\".deleted is null");
			
			// @author wang.wei 2012/3/3 add start
			$this->memberdata_init($id1,$mem,'insert');
			// @author wang.wei 2012/3/3 add end
			
			$condition = " kbn='nationality_id' and deleted is null";
			$birthday = $mem['Member']['birthday'];
			$delete = array();
			$delete = split('-', $birthday);
			$mem['Birthday']['yyyy'] = $delete[0];
			$mem['Birthday']['mm'] = $delete[1];
			$mem['Birthday']['dd'] = $delete[2];
			
			$country_list = $this->SysParams->generateList($condition, 'sort');
			$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
			
			$pid = $mem['Member']['address_nation_id'];

			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid . " and deleted is null";
				$city_list = $this->SysParams->generateList($condition2, 'sort');
				$this->set("city_list", $city_list);
			}		
			
			$this->myInit();
			$this->set("myMember", $mem);
			$this->data = $mem;
			$this->set("job_id", $id);
			$this->render('revisemem');
			exit();
		} else {
			$this->render('login');
			
			exit();
		}
	}
	function revisemem() {

	}
	
	function reviseMyMember($id = null) {
		
		// add エラー対策(F7) tsubasa 2012/11/13 start;

		if($this->isCountError($this->data['Member'])) {
			$this->show404();
			exit;
		}
		 
		// add エラー対策(F7) tsubasa 2012/11/13 end;
		
		$this->changeSpecString($this->data['Member']['address_nation_id']);
		$this->changeSpecString($this->data['MemberExpWorktype']['exp_worktype_big']);
		$this->changeSpecString($this->data['Member']['hope_worktype1_big']);
		//$this->changeSpecString($this->data['Member']['login_id']);
		
		// wang.wei add 2012/5/23 start
		$this->Output->htmlspecialchars($this->data);
		// wang.wei add 2012/5/23 end
		$message = '';

		if (empty($this->rdAuth->id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		$id1 = $this->rdAuth->id;
		
		$y = $this->data['Birthday']['yyyy'];
		//			$m=$this->data['Birthday']['mm'];
		//			$d=$this->data['Birthday']['dd'];
		$m = (strlen($this->data['Birthday']['mm']) > 1) ? $this->data['Birthday']['mm'] : '0' . $this->data['Birthday']['mm'];
		$d = (strlen($this->data['Birthday']['dd']) > 1) ? $this->data['Birthday']['dd'] : '0' . $this->data['Birthday']['dd'];
		//pr($this->data['Birthday']['yyyy']);
		$this->data['Member']['birthday'] = $y . "-" . $m . "-" . $d;
		//pr($this->data['Member']['birthday']);
		
		// @author wang.wei 2012/3/15 add start
		$myMember = $this->data;
		$myMember['Member']['hope_income']=str_replace(',','',$myMember['Member']['hope_income']);
		$myMember['Member']['hope_income_to']=str_replace(',','',$myMember['Member']['hope_income_to']);
		// @author wang.wei 2012/3/15 add end
		
		// @author wang.wei 2012/3/2 add start
		$message = $this->Member->memValid2($this->Valid, $myMember);
		$message .= $this->Member->emailValid($this->Valid, $myMember);
		
		if ($this->rdAuth->login_id == $this->data['Member']['login_pwd'] && $this->data['Member']['login_pwd'] != null) {
			$message .= $this->Valid->tagErrorMsg('reg_pwd_repeat',
					'Member/login_pwd');
		}
		
		// @author wang.wei 2012/3/2 add end
		if (empty($message)) {
			$this->data['Member']['id'] = $id1;
			// @author wang.wei 2012/3/6 add start
			$myMem = $this->Member->find(
					"\"Member\".id=" . $id1 . " and \"Member\".deleted is null");
			$myMember['Member']['login_id'] = $myMem['Member']['login_id'];
			$myMember['Member']['created'] = $myMem['Member']['created'];
			// @author wang.wei 2012/3/6 add end
			// @author wang.wei 2012/3/7 add start
			$this->memberdata_beforeConfirm($myMember);
			// @author wang.wei 2012/3/7 add end
			$this->Session->write("myMember", $myMember);
			// @author wang.wei 2012/3/7 add start
			$this->memberdata_beforeSave($myMember);
			// @author wang.wei 2012/3/7 add end

			$myMember = $this->setMem($myMember);
			$this->set("job_id", $id);
			$this->set("myMember", $myMember);
		
			$this->render('revisefinish');
			exit();
		} else {
			// @author wang.wei 2012/3/6 add start
			$myMem = $this->Member->find(
					"\"Member\".id=" . $id1 . " and \"Member\".deleted is null");
			$myMember['Member']['login_id'] = $myMem['Member']['login_id'];
			$myMember['Member']['created'] = $myMem['Member']['created'];
			// @author wang.wei 2012/3/6 add end
			$mem = $this->setMem($myMember);
			$condition = " kbn='nationality_id' and deleted is null";
			
			$country_list = $this->SysParams->generateList($condition, 'sort');
			$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
			$this->set("country_list", $country_list);
			$this->set("country_list2", $country_list2);
			$mem['Member']['id'] = $id1;
			$pid = $mem['Member']['address_nation_id'];
			
			if ($this->Valid->number($pid)) {
				$condition2 = " kbn ='city_id' and pid=" . $pid . " and deleted is null";

				$city_list = $this->SysParams->generateList($condition2, 'sort');
				
				$this->set("city_list", $city_list);
				
			}			
			// @author wang.wei 2012/3/3 add start
			//$this->memberdata_confirm($mem);
			$this->memberdata_init($id1,$mem,'update');
			// @author wang.wei 2012/3/3 add end
			$this->myInit();
			$this->set("myMember", $mem);
			$this->set("job_id", $id);
			$this->set("message", $message);
			$this->render('revisemem');
			exit();
		}
	}
	function revisefinish() {

	}
	
	function revisefinal($id = null) {
		
		if (empty($this->rdAuth->id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		
		if (!$this->Session->check('myMember')) {
			$this->showError('session_expired');
		}
		
		$member = $this->Session->read("myMember");
		
		if (isset($member['Member']['login_pwd'])) {
			$member['Member']['login_pwd'] = trim(
				$member['Member']['login_pwd']);
			if (!empty($member['Member']['login_pwd'])) {
				$member['Member']['login_pwd'] = Md5(
					$member['Member']['login_pwd']);
			} else {
				unset($member['Member']['login_pwd']);
			}
		}
		
// 		if (isset($member['Member']['grad_date']) && empty(
// 			$member['Member']['grad_date'])) {
// 			unset($member['Member']['grad_date']);
// 		}
		
		if (isset($member['Member']['email']) && empty(
			$member['Member']['email'])) {
			unset($member['Member']['email']);
		}
		
		// @author wang.wei 2012/3/3 add start
		$this->memberdata_save($member,'update');
		// @author wang.wei 2012/3/3 add end
		//$this->Member->save($member);
		
		$this->Session->del("myMember");
		
		$member = $this->Member->find(
			"\"Member\".id=" . $member['Member']['id'] . " and \"Member\".deleted is null");
		
		$this->rdAuth->set($member['Member']);
		if ($_SESSION['yyyy'] != null) {
			$_SESSION['yyyy'] = null;
		}
		if ($_SESSION['mm'] != null) {
			$_SESSION['mm'] = null;
		}
		$this->redirect("/search/order_input/" . $id . "/false");
		exit();
	}
	function setMem($data) {
		
		if (!empty($data['Member']['sex_id'])) {
			$sex_list = $this->SysParams->generateList(
				"kbn='sex_id' and deleted is null");
			$data['SysParams4']['name'] = $this->Valid->getOptionValue($data, 
				'Member/sex_id', $sex_list);
		}
		
		$work_list = $this->SysParams->generateList(
			"kbn = 'interest_work_type_id' and deleted is null");
		$language_list = $this->SysParams->generateList(
			"kbn='language_id' and deleted is null ");
		$mail_list = $this->SysParams->generateList(
			"kbn='mailmaga_flg' and deleted is null");
		
		// @author wang.wei 2012/3/9 add update
		if (!empty($data['Member']['nationality_id'])) {
			if($data['Member']['nationality_id']==4){
				$data['SysParams1']['name']=$data['Member']['other_language'];
			}else{
				$country_list1 = $this->SysParams->generateList(
					"kbn='nationality_id' and deleted is null", 'sort');
				$data['SysParams1']['name'] = $this->Valid->getOptionValue($data, 
					'Member/nationality_id', $country_list1);
			}
		}
		/* if (!empty($data['Member']['nationality_id'])) {
			$country_list1 = $this->SysParams->generateList(
					"kbn='nationality_id' and deleted is null", 'sort');
			$data['SysParams1']['name'] = $this->Valid->getOptionValue($data,
					'Member/nationality_id', $country_list1);
		} */
		// @author wang.wei 2012/3/9 end update
		if (!empty($data['Member']['address_nation_id'])) {
			$country_list = $this->SysParams->generateList(
				"kbn='country_id' and deleted is null");
			$data['SysParams5']['name'] = $this->Valid->getOptionValue($data, 
				'Member/address_nation_id', $country_list);
		}
		if (!empty($data['Member']['address_location_id'])
				&& $this->Valid->number($data['Member']['address_location_id'])){
			$city_list = $this->SysParams->generateList(
				"kbn='city_id' and pid=" . $data['Member']['address_nation_id'] . " and deleted is null", 
				'sort');
			$data['SysParams3']['name'] = $this->Valid->getOptionValue($data, 
				'Member/address_location_id', $city_list);
		}
		if (!empty($data['Member']['education_id'])) {
			$overseas_work_position_list = $this->SysParams->generateList(
				"kbn = 'education_id' and deleted is null");
			$data['SysParams13']['name'] = $this->Valid->getOptionValue($data, 
				'Member/education_id', $overseas_work_position_list);
		}
// 		if (!empty($data['Member']['work_type_id1'])) {
// 			$data['SysParams6']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/work_type_id1', $work_list);
// 		}
// 		if (!empty($data['Member']['work_type_id2'])) {
// 			$data['SysParams7']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/work_type_id2', $work_list);
// 		}
// 		if (!empty($data['Member']['work_type_id3'])) {
// 			$data['SysParams8']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/work_type_id3', $work_list);
// 		}
// 		if (!empty($data['Member']['interest_work_type_id1'])) {
// 			$data['SysParams9']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/interest_work_type_id1', $work_list);
// 		}
// 		if (!empty($data['Member']['interest_work_type_id2'])) {
// 			$data['SysParams10']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/interest_work_type_id2', $work_list);
// 		}
// 		if (!empty($data['Member']['interest_work_type_id3'])) {
// 			$data['SysParams11']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/interest_work_type_id3', $work_list);
// 		}
		if (!empty($data['Member']['work_status_id'])) {
			$work_status_list = $this->SysParams->generateList(
				"kbn='work_status_id' and deleted is null");
			$data['SysParams12']['name'] = $this->Valid->getOptionValue($data, 
				'Member/work_status_id', $work_status_list);
		}
// 		if (!empty($data['Member']['language_jp_id'])) {
// 			$data['SysParams14']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_jp_id', $language_list);
// 		}
// 		if (!empty($data['Member']['language_ch_bj_id'])) {
// 			$data['SysParams18']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_ch_bj_id', $language_list);
// 		}
// 		if (!empty($data['Member']['language_en_id'])) {
// 			$data['SysParams16']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_en_id', $language_list);
// 		}
// 		if (!empty($data['Member']['language_ch_gd_id'])) {
// 			$data['SysParams15']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_ch_gd_id', $language_list);
// 		}
// 		if (!empty($data['Member']['language_other_id1'])) {
// 			$data['SysParams17']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_other_id1', $language_list);
// 		}
// 		if (!empty($data['Member']['language_other_id2'])) {
// 			$data['SysParams19']['name'] = $this->Valid->getOptionValue($data, 
// 				'Member/language_other_id2', $language_list);
// 		}
		if (!empty($data['Member']['pwd_remain_id'])) {
			$remain_list = $this->SysParams->generateList(
				"kbn='password_question_id' and deleted is null");
			$data['SysParams20']['name'] = $this->Valid->getOptionValue($data, 
				'Member/pwd_remain_id', $remain_list);
		}
		if (!empty($data['Member']['new_mail_flg'])) {
			$data['SysParams21']['name'] = $this->Valid->getOptionValue($data, 
				'Member/new_mail_flg', $mail_list);
		}
		if (!empty($data['Member']['mailmaga_flg'])) {
			$data['SysParams2']['name'] = $this->Valid->getOptionValue($data, 
				'Member/mailmaga_flg', $mail_list);
		}
		
		// @author wang.wei 2012/2/27 add start

		$country_list = $this->SysParams->generateList(
				"kbn = 'nationality_id' and deleted is null");
		$country_list2 = $this->SysParams->generateList(
				"kbn = 'country_id' and deleted is null",'sort');
		
		for($i=1; $i<=$data['Member']['member_overseas_edu_count'] ;$i++){
			if (!empty($data['Member']['overseas_edu'.$i.'_nation'])) {
				$data['SysParams23']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_edu'.$i.'_nation', $country_list2);
			}
			if (!empty($data['Member']['overseas_edu'.$i.'_period'])) {
				$overseas_edu_period_list = $this->SysParams->generateList(
						"kbn='overseas_edu_period' and deleted is null");
				$data['SysParams24']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_edu'.$i.'_period', $overseas_edu_period_list);
			}
			if (!empty($data['Member']['overseas_edu'.$i.'_purpose'])) {
				$overseas_edu_purpose_list = $this->SysParams->generateList(
						"kbn='overseas_edu_purpose' and deleted is null");
				$data['SysParams25']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_edu'.$i.'_purpose', $overseas_edu_purpose_list);
			}
		}
		
		for($i=1; $i<=$data['Member']['member_overseas_work_count'] ;$i++){
			if (!empty($data['Member']['overseas_work'.$i.'_nation'])) {
				$data['SysParams26']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_work'.$i.'_nation', $country_list2);
			}
			if (!empty($data['Member']['overseas_work'.$i.'_period'])) {
				$overseas_work_periodn_list = $this->SysParams->generateList(
						"kbn='overseas_work_period' and deleted is null");
				$data['SysParams27']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_work'.$i.'_period', $overseas_work_periodn_list);
			}
			if (!empty($data['Member']['overseas_work'.$i.'_position'])) {
				$overseas_work_positionn_list = $this->SysParams->generateList(
						"kbn='overseas_work_position' and deleted is null");
				$data['SysParams28']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/overseas_work'.$i.'_position', $overseas_work_positionn_list);
			}
		}
		
		//@author wang.wei 2012/3/19 update start
		for($i=1; $i<=$data['Member']['member_lang_count'] ;$i++){
			if (!empty($data['Member']['foreign_lang'.$i])) {
				$data['SysParams29']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/foreign_lang'.$i, $country_list);
			}
			if (!empty($data['Member']['foreign_lang_level'.$i])) {
				$language_level_list = $this->SysParams->generateList(
						"kbn='language_level' and deleted is null");
				$data['SysParams30']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/foreign_lang_level'.$i, $language_level_list);
			}
		}
		//@author wang.wei 2012/3/19 update end
		
		if($data['Member']['work_visa_flg']=='0'){
			$data['SysParams31']['name']='有り ';
		}elseif($data['Member']['work_visa_flg']=='1'){
			$data['SysParams31']['name']='無し';
		}
		
		// @author wang.wei 2012/3/9 update start
		if (!empty($data['Member']['work_visa_nation'])) {
			$data['SysParams32']['name'] = $this->Valid->getOptionValue($data,
					'Member/work_visa_nation', $country_list2);
		}
		// @author wang.wei 2012/3/9 update end
		
		if (!empty($data['Member']['change_work_will'])) {
			$change_work_will_list = $this->SysParams->generateList(
					"kbn='change_work_will' and deleted is null");
			$data['SysParams33']['name'] = $this->Valid->getOptionValue($data,
					'Member/change_work_will', $change_work_will_list);
		}
		
		for($i=1; $i<=$data['Member']['member_hope_work_location_count'] ;$i++){
			if (!empty($data['Member']['hope_work_location'.$i])) {
				$hope_work_location_list = $this->SysParams->generateList(
						"kbn='hope_work_location' and deleted is null order by id");
				$data['SysParams34']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/hope_work_location'.$i, $hope_work_location_list);
			}
		}
		
		for($i=1; $i<=$data['Member']['member_hope_category_count'] ;$i++){
			if (!empty($data['Member']['hope_category'.$i])) {
				$hope_category_list = $this->SysParams->generateList(
						"kbn = 'gyoshu_id' and deleted is null order by id");
				$data['SysParams35']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/hope_category'.$i, $hope_category_list);
			}
		}
		
		for($i=1; $i<=$data['Member']['member_hope_worktype_count'] ;$i++){	
			if (!empty($data['Member']['hope_worktype'.$i.'_big'])) {
				$hope_worktype_big_list = $this->SysParams->generateList(
						"kbn = 'shokusyu_id' and (pid in (1000,2000,3000,4000,5000,6000,7000,8000,9000) or id in (1000,2000,3000,4000,5000,6000,7000,8000,9000)) and deleted is null order by id");
				$data['SysParams36']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/hope_worktype'.$i.'_big', $hope_worktype_big_list);
			}
			if (!empty($data['Member']['hope_worktype'.$i.'_small'])) {
				$p = $data['Member']['hope_worktype'.$i.'_big'];
				if ($this->Valid->number($p)) {
					$hope_worktype_small_list = $this->SysParams->generateList(
							"kbn = 'shokusyu_id' and pid=" . $p);
				}
				$data['SysParams37']['name'][$i] = $this->Valid->getOptionValue($data,
						'Member/hope_worktype'.$i.'_small', $hope_worktype_small_list);
			}
		}
		
		if ($data['Member']['hope_income_flg']=='1') {
			$data['SysParams38']['name'] = $this->Valid->label('Member/hope_income_flg_title');
		}else{
			$hope_income_cur_list = $this->SysParams->generateList(
					"kbn='income_cur' and deleted is null");
			
			/* wang.wei 2012/12/10 update start*/
			if(!empty($data['Member']['hope_income']) && empty($data['Member']['hope_income_to'])){
				$data['SysParams38']['name'] = number_format($data['Member']['hope_income'])." ".$this->Valid->getOptionValue($data,
						'Member/hope_income_cur', $hope_income_cur_list) . '以上';
			}
			else if(!empty($data['Member']['hope_income_to']) && empty($data['Member']['hope_income'])){
				$data['SysParams38']['name'] = number_format($data['Member']['hope_income_to'])." ".$this->Valid->getOptionValue($data,
						'Member/hope_income_cur', $hope_income_cur_list). '以下';
			}else{
				$data['SysParams38']['name'] = number_format($data['Member']['hope_income'])." ～ ".number_format($data['Member']['hope_income_to'])." ".$this->Valid->getOptionValue($data,
							'Member/hope_income_cur', $hope_income_cur_list);
			}
			
			// @author wang.wei 2012/3/15 update start
			//$data['SysParams38']['name'] = number_format($data['Member']['hope_income'])." ".$this->Valid->getOptionValue($data,
			//		'Member/hope_income_cur', $hope_income_cur_list);
			// @author wang.wei 2012/3/15 update end
			/* wang.wei 2012/12/10 update end*/
		}
		if ($data['Member']['hope_work_location_flg']=='0') {
			$data['SysParams39']['name'] = $this->Valid->label('Member/hope_work_location_flg_title0');
		}else{
			$data['SysParams39']['name'] = $this->Valid->label('Member/hope_work_location_flg_title1');
		}
		
		if (!empty($data['MemberEducation']['edu_degree'])) {
			$edu_degreen_list = $this->SysParams->generateList(
					"kbn = 'education_id' and deleted is null");
			$data['SysParams41']['name'] = $this->Valid->getOptionValue($data,
					'MemberEducation/edu_degree', $edu_degreen_list);
		}
		
		$data = $this->setMemberExpWorktype($data);
		// @author wang.wei 2012/2/27 add end
	
		return $data;
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/10
	* 履歴書
	* */
	function resume($id = null) {
		$this->setHead();
		
		if ($id == 'back' && $this->Session->check('myMemberResume')) {
			$member = $this->Session->read("myMemberResume");
			for($i = 0; $i < count($member['MemberEducation']['edu_school']); $i++) {
				if ($i < 1) {
					$member['MemberEducation']['name'][$i] = $this->Valid->label(
						'MemberEducation/name1');
				} else {
					$member['MemberEducation']['name'][$i] = $this->Valid->label(
						'MemberEducation/name2');
				}
			}
			for($i = 0; $i < count($member['MemberWork']['exp_work_locaiton']); $i++) {
				if ($i < 1) {
					$member['MemberWork']['name'][$i] = $this->Valid->label(
							'MemberWork/name1');
				} else {
					$member['MemberWork']['name'][$i] = '';
				}
			}
			for($i = 0; $i < count($member['MemberExpWorktype']['exp_category']); $i++) {
				if(!empty($member['MemberExpWorktype']['exp_worktype_big'][$i])
						&& $this->Valid->number($member['MemberExpWorktype']['exp_worktype_big'][$i])) {
					$p = $member['MemberExpWorktype']['exp_worktype_big'][$i];
					$condition = " kbn ='shokusyu_id' and pid=" . $p;
					$exp_worktype_small_list = $this->SysParams->generateList(
						$condition);
					$this->set("exp_worktype_small_list".$i, $exp_worktype_small_list);
				}else{
					//add by wang.wei 2012/3/22
					$this->set("exp_worktype_small_list".$i, array());
				}
			}
			$this->resumeInit();
			$this->set("myMember", $member);
			$this->set("myMemberResume", $member);
			$this->data = $member;
			$this->render('resume');
			exit();
		} else {
			$this->Session->del("myMemberResume");
			$return_id = $id;
			$id = $this->rdAuth->id;
			
			if (!empty($id)) {
				$dbMR = $this->Common->getMemberResumeDataByMemberid($id);
				if ($dbMR["MemberResume"]["member_id"] == $id) {
					$this->pageTitle = "履歴書編集";
					
					$dbME = $this->Common->getMemberEducationDataByMemberid($id, null, "\"MemberEducation\".id asc");
					$dbMW = $this->Common->getMemberWorkDataByMemberid($id, null, "\"MemberWork\".id asc");
					$dbMEW = $this->Common->getMemberExpWorktypeDataByMemberid($id, null, "\"MemberExpWorktype\".id asc");
					$myMemberResume['MemberResume'] = $dbMR['MemberResume'];
					
					for($i = 0; $i < count($dbME); $i++) {
						$myMemberResume['MemberEducation']['id'][$i] = $dbME[$i]['MemberEducation']['id'];
						$myMemberResume['MemberEducation']['edu_school'][$i] = $dbME[$i]['MemberEducation']['edu_school'];
						$myMemberResume['MemberEducation']['edu_dep'][$i] = $dbME[$i]['MemberEducation']['edu_dep'];
						$myMemberResume['MemberEducation']['edu_degree'][$i] = $dbME[$i]['MemberEducation']['edu_degree'];
						$myMemberResume['MemberEducation']['edu_status'][$i] = $dbME[$i]['MemberEducation']['edu_status'];
						list($edu_start, $edu_start_month, $edu_end, $edu_end_month) = split(
							'[-.-]', 
							$dbME[$i]['MemberEducation']['edu_start'] . '-' . $dbME[$i]['MemberEducation']['edu_end']);
						$myMemberResume['MemberEducation']['edu_start'][$i] = $edu_start;
						$myMemberResume['MemberEducation']['edu_start_month'][$i] = $edu_start_month;
						$myMemberResume['MemberEducation']['edu_end'][$i] = $edu_end;
						$myMemberResume['MemberEducation']['edu_end_month'][$i] = $edu_end_month;
					}
					for($i = 0; $i < count($dbMW); $i++) {
						$myMemberResume['MemberWork']['id'][$i] = $dbMW[$i]['MemberWork']['id'];
						$myMemberResume['MemberWork']['exp_work_locaiton'][$i] = $dbMW[$i]['MemberWork']['exp_work_locaiton'];
						$myMemberResume['MemberWork']['exp_work_public_flg' . $i] = $dbMW[$i]['MemberWork']['exp_work_public_flg'];
						$myMemberResume['MemberWork']['exp_work_start_year'][$i] = $dbMW[$i]['MemberWork']['exp_work_start_year'];
						$myMemberResume['MemberWork']['exp_work_start_month'][$i] = $dbMW[$i]['MemberWork']['exp_work_start_month'];
						$myMemberResume['MemberWork']['exp_work_end_year'][$i] = $dbMW[$i]['MemberWork']['exp_work_end_year'];
						$myMemberResume['MemberWork']['exp_work_end_month'][$i] = $dbMW[$i]['MemberWork']['exp_work_end_month'];
						$myMemberResume['MemberWork']['exp_work_position'][$i] = $dbMW[$i]['MemberWork']['exp_work_position'];
						$myMemberResume['MemberWork']['exp_work_emp_type'][$i] = $dbMW[$i]['MemberWork']['exp_work_emp_type'];
						$myMemberResume['MemberWork']['exp_work_flg'][$i] = $dbMW[$i]['MemberWork']['exp_work_flg'];
						/* add by wang.wei 2012/12/07 start */
						$myMemberResume['MemberWork']['exp_work_content'][$i] = $dbMW[$i]['MemberWork']['exp_work_content'];
						/* add by wang.wei 2012/12/07 end */
						if ($myMemberResume['MemberWork']['exp_work_flg'][$i] == 0) {
							$myMemberResume['MemberWork']['exp_work_end_year'][$i] = $this->Valid->label(
								'MemberWork/exp_work_flg_value');
						}
					
					}
					for($i = 0; $i < count($dbMEW); $i++) {
						$myMemberResume['MemberExpWorktype']['id'][$i] = $dbMEW[$i]['MemberExpWorktype']['id'];
						$myMemberResume['MemberExpWorktype']['exp_category'][$i] = $dbMEW[$i]['MemberExpWorktype']['exp_category'];
						$myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i] = $dbMEW[$i]['MemberExpWorktype']['exp_worktype_big'];
						$myMemberResume['MemberExpWorktype']['exp_worktype_small'][$i] = $dbMEW[$i]['MemberExpWorktype']['exp_worktype_small'];
						$myMemberResume['MemberExpWorktype']['exp_year'][$i] = $dbMEW[$i]['MemberExpWorktype']['exp_year'];
						
						if(!empty($myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i])
								&& $this->Valid->number($myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i])) {
							$p = $myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i];
							$condition = " kbn ='shokusyu_id' and pid=" . $p;
							$exp_worktype_small_list = $this->SysParams->generateList(
								$condition);
							$this->set("exp_worktype_small_list".$i, 
								$exp_worktype_small_list);
						}else{
							//add by wang.wei 2012/3/22
							$this->set("exp_worktype_small_list".$i, array());
						}

					
					}
					$myMemberResume['op'] = 'update';
					//wang.wei 2012/4/6 add start
					$myMemberResume['MemberResume']['btnok_value']='確 認';
					//wang.wei 2012/4/6 add end
					
				} else {
					
					$this->pageTitle = "履歴書登録";
					$me = $this->MemberEducation->find(
						"\"MemberEducation\".member_id=" . $id . " and \"MemberEducation\".deleted is null", 
						"id,edu_degree", 
						"order by \"MemberEducation\".id");
					
					$mew = $this->Common->getMemberExpWorktypeDataByMemberid($id,
																			null,
																			"\"MemberExpWorktype\".id asc");
					
					$this->Session->write("Me_last_edu_degree",$me['MemberEducation']['id']);
					
					$myMember = $this->data['Member'];
					for($i=0; $i<count($mew); $i++){
						$myMemberResume['MemberExpWorktype']['id'][$i]=$mew[$i]['MemberExpWorktype']['id'];
						$myMemberResume['MemberExpWorktype']['exp_category'][$i]=$mew[$i]['MemberExpWorktype']['exp_category'];
						$myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i]=$mew[$i]['MemberExpWorktype']['exp_worktype_big'];
						$myMemberResume['MemberExpWorktype']['exp_worktype_small'][$i]=$mew[$i]['MemberExpWorktype']['exp_worktype_small'];
						$myMemberResume['MemberExpWorktype']['exp_year'][$i]=$mew[$i]['MemberExpWorktype']['exp_year'];
						
						if(!empty($myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i])
								&& $this->Valid->number($myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i])) {
							$p = $myMemberResume['MemberExpWorktype']['exp_worktype_big'][$i];
							$condition = " kbn ='shokusyu_id' and pid=" . $p;
							$exp_worktype_small_list = $this->SysParams->generateList(
									$condition);
							$this->set("exp_worktype_small_list".$i, $exp_worktype_small_list);
						}else{
							//add by wang.wei 2012/3/22
							$this->set("exp_worktype_small_list".$i, array());
						}
						
					}
					$myMemberResume['MemberEducation']['id'][0] = $me['MemberEducation']['id'];
					$myMemberResume['MemberEducation']['edu_degree'][0] = $me['MemberEducation']['edu_degree'];
					$myMemberResume['MemberEducation']['id'][0] = $me['MemberEducation']['id'];
					
					if(empty($myMemberResume['MemberEducation']['edu_school'][0])){
						$myMemberResume['MemberEducation']['edu_school'] = '';
					}
					if(empty($myMemberResume['MemberWork']['exp_work_locaiton'][0])){
						$myMemberResume['MemberWork']['exp_work_locaiton'] = '';
					}
					if(empty($myMemberResume['MemberExpWorktype']['exp_category'][0])){
						$myMemberResume['MemberExpWorktype']['exp_category'] = '';
					}
					$myMemberResume['op'] = 'insert';
					//wang.wei 2012/4/6 add start
					$myMemberResume['MemberResume']['btnok_value']='確 認';
					//wang.wei 2012/4/6 add end
				}
				
				for($i = 0; $i < count(
					$myMemberResume['MemberEducation']['edu_school']); $i++) {
					if ($i < 1) {
						$myMemberResume['MemberEducation']['name'][$i] = $this->Valid->label(
							'MemberEducation/name1');
					} else {
						$myMemberResume['MemberEducation']['name'][$i] = $this->Valid->label(
							'MemberEducation/name2');
					}
				}
				for($i = 0; $i < count(
					$myMemberResume['MemberWork']['exp_work_locaiton']); $i++) {
					if ($i < 1) {
						$myMemberResume['MemberWork']['name'][$i] = $this->Valid->label(
							'MemberWork/name1');
					} else {
						$myMemberResume['MemberWork']['name'][$i] = '';
					}
				}

				if($return_id=='resumeshow'){
					$myMemberResume['MemberResume']['return_id']='resumeshow';
					$myMemberResume['MemberResume']['return_url']='/member/resumeshow';
					$myMemberResume['MemberResume']['return_value']='戻る';
				}elseif($return_id=='order_input'){
					$order_id = $this->Session->read("order_id");
					$myMemberResume['MemberResume']['return_id']='order_input';
					$myMemberResume['MemberResume']['return_url']='/search/order_input/'.$order_id;
					$myMemberResume['MemberResume']['return_value']='キャンセル';
					//@author wangyuhua 2012/3/31 update 注释了下行代码
// 					$this->Session->del("order_id");
				}elseif($return_id=='reg_resume'){
					$myMemberResume['MemberResume']['return_id']='reg_resume';
					$myMemberResume['MemberResume']['return_url']=FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login';
					$myMemberResume['MemberResume']['return_value']='戻る';
				}else{
					$myMemberResume['MemberResume']['return_id']='';
					$myMemberResume['MemberResume']['return_url']=FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login';
					$myMemberResume['MemberResume']['return_value']='戻る';
				}
				
				$this->resumeInit();
				$this->set("myMember", $myMember);
				$this->set("myMemberResume", $myMemberResume);
				$this->set("htmlValid", '0');
				$this->render('resume');
				exit();
			} else {
				$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
				exit();
			}
		}
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/13
	* */
	function remResume($id = null) {
		
		$this->changeSpecString($this->data['Member']['address_nation_id']);
		$this->changeSpecString($this->data['MemberExpWorktype']['exp_worktype_big']);
		$this->changeSpecString($this->data['Member']['hope_worktype1_big']);
		//$this->changeSpecString($this->data['Member']['login_id']);
		
		// wang.wei add 2012/5/23 start
		$this->Output->htmlspecialchars($this->data);
		// wang.wei add 2012/5/23 end
		$this->setHead();
		$member = $this->data;

		$id = $this->rdAuth->id;
		if (empty($id) || $id == null) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		for($i = 0; $i < count($member['MemberExpWorktype']['exp_category']); $i++) {
			if(!empty($member['MemberExpWorktype']['exp_worktype_big'][$i])
					&& $this->Valid->number($member['MemberExpWorktype']['exp_worktype_big'][$i])) {
				$p = $member['MemberExpWorktype']['exp_worktype_big'][$i];
				$condition = " kbn ='shokusyu_id' and pid=" . $p;
				$exp_worktype_small_list = $this->SysParams->generateList(
					$condition);
				$this->set("exp_worktype_small_list".$i, $exp_worktype_small_list);
			}else{
				//add by wang.wei 2012/3/22
				$this->set("exp_worktype_small_list".$i, array());
			}
		}
		
		// @author wang.wei 2012/3/15 add start
		$member['MemberResume']['now_income']=str_replace(',','',$member['MemberResume']['now_income']);
		// @author wang.wei 2012/3/15 add end
		
		$message = $this->MemberResume->RegValid($this->Valid, $member);
		
		for($i = 0; $i < count($member['MemberEducation']['edu_school']); $i++) {
			if ($i < 1) {
				$member['MemberEducation']['name'][$i] = $this->Valid->label(
					'MemberEducation/name1');
			} else {
				$member['MemberEducation']['name'][$i] = $this->Valid->label(
					'MemberEducation/name2');
			}
		}
		if (empty($message)) {
			if($member['MemberResume']['return_id']=='order_input'){
				$member['MemberResume']['confirm_value']='確 定';
			}else{
				$member['MemberResume']['confirm_value']='登 録';
			}
			$member = $this->setMemberResume($member);
			$this->Session->write("myMemberResume", $member);
			$this->set("myMemberResume", $member);
			$order_id = $this->Session->read("order_id");
			$this->render("resume2");
			exit();
		
		} else {
			$this->resumeInit();
			$this->Session->write("myMemberResume", $member);
			$this->set("myMember", $member);
			$this->set("myMemberResume", $member);
			$this->data = $member;
			$this->set("message", $message);
			$this->set("htmlValid", 
				implode(',', $this->MemberResume->htmlValid));
			$this->render('resume');
			exit();
		}
	
	}
	
	function resume3() {
		$this->setHead();
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
		$member = $this->Session->read("myMemberResume");

		if ($this->Session->check('myMemberResume')) {
			$member_id = $this->rdAuth->id;

			//$this->MemberEducation->doDelete(implode(',', $myDBMemberResume['MemberEducation']['id']));
			//$this->MemberExpWorktype->doDelete(implode(',', $myDBMemberResume['MemberExpWorktype']['id']));
			//$this->MemberWork->doDelete(implode(',', $myDBMemberResume['MemberWork']['id']));
			
			$this->MemberEducation->doDeleteFormMemberId($member_id);
			$this->MemberExpWorktype->doDeleteFormMemberId($member_id);
			$this->MemberWork->doDeleteFormMemberId($member_id);
				
			$MemberEducation = array();
			if ($member['MemberResume']['op'] == 'insert') {
				$this->MemberEducation->doDelete(
					implode(',', $member['MemberEducation']['id'][0]));
			}
			for($i = 0; $i < count($member['MemberEducation']['edu_school']); $i++) {
				//$meid=$this->Session->read("Me_last_edu_degree");
				$MemberEducation['member_id'] = $member_id;
				$MemberEducation['edu_school'] = $member['MemberEducation']['edu_school'][$i];
				$MemberEducation['edu_dep'] = $member['MemberEducation']['edu_dep'][$i];
				$MemberEducation['edu_degree'] = $member['MemberEducation']['edu_degree'][$i];
				$MemberEducation['edu_status'] = $member['MemberEducation']['edu_status'][$i];
				if(!empty($member['MemberEducation']['edu_start'][$i])){
					$MemberEducation['edu_start'] = $member['MemberEducation']['edu_start'][$i] . '-' . $member['MemberEducation']['edu_start_month'][$i];
				}
				if(!empty($member['MemberEducation']['edu_end'][$i])){
					$MemberEducation['edu_end'] = $member['MemberEducation']['edu_end'][$i] . '-' . $member['MemberEducation']['edu_end_month'][$i];
				}
				$this->MemberEducation->create();
				$this->MemberEducation->save($MemberEducation);
				// @author wang.wei 2012/3/12 add start
				$MemberEducation['edu_start'] = null;
				$MemberEducation['edu_end'] = null;
				// @author wang.wei 2012/3/12 add end
			}
			
			$MemberWork = array();
			for($i = 0; $i < count($member['MemberWork']['exp_work_locaiton']); $i++) {
				$MemberWork['member_id'] = $member_id;
				$MemberWork['exp_work_locaiton'] = $member['MemberWork']['exp_work_locaiton'][$i];
				$MemberWork['exp_work_start_year'] = $member['MemberWork']['exp_work_start_year'][$i];
				$MemberWork['exp_work_start_month'] = $member['MemberWork']['exp_work_start_month'][$i];
				$MemberWork['exp_work_end_month'] = $member['MemberWork']['exp_work_end_month'][$i];
				//$MemberWork['exp_work_flg']=$member['MemberWork']['exp_work_flg'.$i];
				$MemberWork['exp_work_position'] = $member['MemberWork']['exp_work_position'][$i];
				$MemberWork['exp_work_emp_type'] = $member['MemberWork']['exp_work_emp_type'][$i];
				$MemberWork['exp_work_public_flg'] = $member['MemberWork']['exp_work_public_flg' . $i];
				/* add by wang.wei 2012/12/07 start */
				$MemberWork['exp_work_content'] = $member['MemberWork']['exp_work_content'][$i];
				/* add by wang.wei 2012/12/07 end */
				if ($member['MemberWork']['exp_work_end_year'][$i] == $this->Valid->label(
					'MemberWork/exp_work_flg_value')) {
					$MemberWork['exp_work_flg'] = 0;
					$MemberWork['exp_work_end_year'] = '';
				} else {
					$MemberWork['exp_work_end_year'] = $member['MemberWork']['exp_work_end_year'][$i];
					$MemberWork['exp_work_flg'] = 1;
				}
				
				$this->MemberWork->create();
				$this->MemberWork->save($MemberWork);
			}
			
			$MemberExpWorktype = array();
			for($i = 0; $i < count($member['MemberExpWorktype']['exp_category']); $i++) {
				$MemberExpWorktype['member_id'] = $member_id;
				$MemberExpWorktype['exp_category'] = $member['MemberExpWorktype']['exp_category'][$i];
				$MemberExpWorktype['exp_worktype_big'] = $member['MemberExpWorktype']['exp_worktype_big'][$i];
				$MemberExpWorktype['exp_worktype_small'] = $member['MemberExpWorktype']['exp_worktype_small'][$i];
				$MemberExpWorktype['exp_year'] = $member['MemberExpWorktype']['exp_year'][$i];
				$this->MemberExpWorktype->create();
				$this->MemberExpWorktype->save($MemberExpWorktype);
			}
			
			$MemberResume = $member['MemberResume'];
			$MemberResume['member_id'] = $member_id;
			
			$oldData = $this->MemberResume->find("\"MemberResume\".member_id=" . $member_id);

			if (!empty($oldData)){
				$MemberResume['id'] = $oldData['MemberResume']['id'];
				$this->MemberResume->save($MemberResume);
			} else {
				$this->MemberResume->create();
				$this->MemberResume->save($MemberResume);
			}

			// @author wang.wei 2012/2/29 add start
			$this->Common->updateMemberInfoAndMemberResumePoint($member_id);
			// @author wang.wei 2012/2/29 add end
		}
		$return_id = $member['MemberResume']['return_id'];
		
		$this->Session->del('myMemberResume');
		
		$order_id = $this->Session->read("order_id");
		if($return_id=='order_input'){
			$this->redirect("/search/order_input/" . $order_id . "/false");
			exit;
		}
		if ($member['MemberResume']['op'] == 'insert') {
			$this->render('resume3');
			exit();
		} else {
			$this->render('resume4');
			exit();
		}
	
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/23
	* */
	function resume4() {
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		}
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/02/10
	 * update 2012/3/22
	* */
	function resumeInit() {
		
		$condition = "kbn = 'education_id' and deleted is null";
		$education_list = $this->SysParams->generateList($condition);
		$this->set("education_list", $education_list);
		
		$condition1 = "kbn = 'work_position_id' and deleted is null";
		$exp_work_position_list = $this->SysParams->generateList($condition1);
		$this->set("exp_work_position_list", $exp_work_position_list);
		
		$condition2 = "kbn = 'work_emp_type_id' and deleted is null";
		$exp_work_emp_type_list = $this->SysParams->generateList($condition2);
		$this->set("exp_work_emp_type_list", $exp_work_emp_type_list);
		
		$condition3 = "kbn = 'gyoshu_id' and deleted is null order by id";
		$exp_category_list = $this->SysParams->generateList($condition3);
		$this->set("exp_category_list", $exp_category_list);
		
		$condition4 = "kbn = 'shokusyu_id' and (pid in (1000,2000,3000,4000,5000,6000,7000,8000,9000) or id in (1000,2000,3000,4000,5000,6000,7000,8000,9000)) and deleted is null order by id";
		$exp_worktype_big_list = $this->SysParams->generateList($condition4);
		$this->set("exp_worktype_big_list", $exp_worktype_big_list);
		
		$condition5 = "kbn = 'income_cur' and deleted is null";
		$now_income_cur_list = $this->SysParams->generateList($condition5);
		$this->set("now_income_cur_list", $now_income_cur_list);
		
		$condition6 = "kbn = 'edu_status' and deleted is null";
		$edu_status_list = $this->SysParams->generateList($condition6);
		$this->set("edu_status_list", $edu_status_list);
		
		$selyearlist = $this->selyearsList('1960', 0, null, null);
		$this->set("selyearlist", $selyearlist);
		
		$selyearlist5 = $this->selyearsList('1960', 5, null, null);
		$this->set("selyearlist5", $selyearlist5);
		
		$selyearlistadd = $this->selyearsList('1960', 0, 
			$this->Valid->label('MemberWork/exp_work_flg_title'), 
			$this->Valid->label('MemberWork/exp_work_flg_value'));
		$this->set("selyearlistadd", $selyearlistadd);
		
		$monthlist = array();
		for($i = 1; $i <= 12; $i++) {
			$monthlist[$i] = $i;
		}
		$this->set("monthlist", $monthlist);
		
		$exp_year_list = array();
		for($i = 1; $i <= 50; $i++) {
			$exp_year_list[$i] = $i;
		}
		$this->set("exp_year_list", $exp_year_list);
		
		$exp_company_list = array();
		for($i = 1; $i <= 40; $i++) {
			$exp_company_list[$i] = $i;
		}
		$this->set("exp_company_list", $exp_company_list);
	
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/10
	* */
	function selyearsList($startyear, $numyear, $addvalue = null, $addindex = null) {
		$year = date("Y") + $numyear;
		$arraylist = array();
		for($i = $startyear; $i <= $year; $i++) {
			$arraylist[$i] = $i;
		}
		if (!empty($addvalue)) {
			$arraylist[$addindex] = $addvalue;
		}
		return $arraylist;
	}
	
	/*
	 * @author wang.wei 
	 * add 2012/02/10
	 * update 2012/3/22
	* */
	function ajax_worktype_small($indexid) {
		$this->layout = 'ajax';
		$p = $this->data['MemberExpWorktype']['exp_worktype_big'][$indexid];
		//update by wang.wei 2012/3/22
		if(empty($p) || !$this->Valid->number($p)){
			$this->set("exp_worktype_small_list", array());
			$this->set("exp_worktype_small_indexid", $indexid);
		}else{
			$condition = " kbn ='shokusyu_id' and pid=" . $p;
			$exp_worktype_small_list = $this->SysParams->generateList($condition, 
				'sort');
			$this->set("exp_worktype_small_list", $exp_worktype_small_list);
			$this->set("exp_worktype_small_indexid", $indexid);
		}

	
	}
	/*
	 * @author wang.wei add
	* 2012/02/13
	* */
	function ajax_membereducation() {
		$this->layout = 'ajax';
		$myMemberResume = $this->Session->read('myMemberResume');
		$this->resumeInit();
		$this->set("myMemberResume", $myMemberResume);
		$this->data = $myMemberResume;
	
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/13
	* */
	function ajax_memberwork() {
		$this->layout = 'ajax';
		$myMemberResume = $this->Session->read('myMemberResume');
		$this->resumeInit();
		$this->set("myMemberResume", $myMemberResume);
		$this->data = $myMemberResume;
	}
	/*
	 * @author wang.wei 
	 * add 2012/02/13
	 * update 2012/3/22
	* */
	function ajax_member_exp_worktype() {
		//add by wang.wei 2012/3/22
		$condition3 = "kbn = 'gyoshu_id' and deleted is null order by id";
		$exp_category_list = $this->SysParams->generateList($condition3);
		$this->set("exp_category_list", $exp_category_list);
		
		$condition4 = "kbn = 'shokusyu_id' and (pid in (1000,2000,3000,4000,5000,6000,7000,8000,9000) or id in (1000,2000,3000,4000,5000,6000,7000,8000,9000)) and deleted is null order by id";
		$exp_worktype_big_list = $this->SysParams->generateList($condition4);
		$this->set("exp_worktype_big_list", $exp_worktype_big_list);
		
		$this->set("exp_worktype_small_list", array());
		
		$exp_year_list = array();
		for($i = 1; $i <= 50; $i++) {
			$exp_year_list[$i] = $i;
		}
		$this->set("exp_year_list", $exp_year_list);
		
	}
	/*
	 * @author wang.wei add
	* 2012/02/15
	* */
	function setMemberResume($data) {
		for($i = 0; $i < count($data['MemberEducation']['edu_degree']); $i++) {
			
			if (!empty($data['MemberEducation']['edu_degree'][$i])) {
				$setdata['MemberEducation']['edu_degree'] = $data['MemberEducation']['edu_degree'][$i];
				$condition1 = "kbn = 'education_id' and deleted is null";
				$education_list = $this->SysParams->generateList($condition1);
				$data['SysParams10']['name'][$i] = $this->Valid->getOptionValue(
					$setdata, 'MemberEducation/edu_degree', $education_list);
			}
			if (!empty($data['MemberEducation']['edu_status'][$i])) {
				$setdata['MemberEducation']['edu_status'] = $data['MemberEducation']['edu_status'][$i];
				$condition1 = "kbn = 'edu_status' and deleted is null";
				$education_list = $this->SysParams->generateList($condition1);
				$data['SysParams11']['name'][$i] = $this->Valid->getOptionValue(
					$setdata, 'MemberEducation/edu_status', $education_list);
			}
		}
		
		for($i = 0; $i < count($data['MemberWork']['exp_work_position']); $i++) {
			if (!empty($data['MemberWork']['exp_work_position'][$i])) {
				$setdata['MemberWork']['exp_work_position'] = $data['MemberWork']['exp_work_position'][$i];
				$condition2 = "kbn = 'work_position_id' and deleted is null";
				$exp_work_position_list = $this->SysParams->generateList(
					$condition2);
				$data['SysParams20']['name'][$i] = $this->Valid->getOptionValue(
					$setdata, 'MemberWork/exp_work_position', 
					$exp_work_position_list);
				
				/* if($data['MemberWork']['exp_work_flg'.$i]=='0'){
					$data['MemberWork']['exp_work_flg_name'][$i]=$this->Valid->label('MemberWork/exp_work_flg_on');
				}else{
					$data['MemberWork']['exp_work_flg_name'][$i]=$this->Valid->label('MemberWork/exp_work_flg_off');
					$data['MemberWork']['exp_work_flg'.$i]='1';
				} */
				
				if ($data['MemberWork']['exp_work_public_flg' . $i] == '1') {
					$data['MemberWork']['exp_work_public_flg_name'][$i] = $this->Valid->label(
						'MemberWork/exp_work_public_flg_on');
				} else {
					$data['MemberWork']['exp_work_public_flg_name'][$i] = $this->Valid->label(
						'MemberWork/exp_work_public_flg_off');
				
				}
			}
			
			if ($data['MemberWork']['exp_work_end_year'][$i] == $this->Valid->label(
					'MemberWork/exp_work_flg_value')) {
					$data['MemberWork']['exp_work_end_year_name'][$i] = $this->Valid->label(
							'MemberWork/exp_work_flg_title');
			} else {
				$data['MemberWork']['exp_work_end_year_name'][$i] = $data['MemberWork']['exp_work_end_year'][$i] . '&nbsp;年&nbsp;' . $data['MemberWork']['exp_work_end_month'][$i] . '&nbsp;月';
			}
			
		}
		
		for($i = 0; $i < count($data['MemberWork']['exp_work_emp_type']); $i++) {
			if (!empty($data['MemberWork']['exp_work_emp_type'][$i])) {
				$setdata['MemberWork']['exp_work_emp_type'] = $data['MemberWork']['exp_work_emp_type'][$i];
				$condition3 = "kbn = 'work_emp_type_id' and deleted is null";
				$exp_work_emp_type_list = $this->SysParams->generateList(
					$condition3);
				$data['SysParams30']['name'][$i] = $this->Valid->getOptionValue(
					$setdata, 'MemberWork/exp_work_emp_type', 
					$exp_work_emp_type_list);
			}
		}

		if (!empty($data['MemberResume']['now_income_cur'])) {
			$condition7 = "kbn = 'income_cur' and deleted is null";
			$now_income_cur_list = $this->SysParams->generateList($condition7);
			$data['SysParams70']['name'] = $this->Valid->getOptionValue($data, 
				'MemberResume/now_income_cur', $now_income_cur_list);
		}
		
		return $this->setMemberExpWorktype($data);
	}
	
	/*
	 * @author wang.wei add
	* 2012/02/15
	* */
	function setMemberExpWorktype($data) {
		for($i = 0; $i < count($data['MemberExpWorktype']['exp_category']); $i++) {
			if (!empty($data['MemberExpWorktype']['exp_category'][$i])) {
				$setdata['MemberExpWorktype']['exp_category'] = $data['MemberExpWorktype']['exp_category'][$i];
				$condition4 = "kbn = 'gyoshu_id' and deleted is null order by id";
				$exp_category_list = $this->SysParams->generateList($condition4);
				$data['SysParams40']['name'][$i] = $this->Valid->getOptionValue(
						$setdata, 'MemberExpWorktype/exp_category',
						$exp_category_list);
			}
			if (!empty($data['MemberExpWorktype']['exp_worktype_big'][$i])) {
				$setdata['MemberExpWorktype']['exp_worktype_big'] = $data['MemberExpWorktype']['exp_worktype_big'][$i];
				$condition5 = "kbn = 'shokusyu_id' and (pid in (1000,2000,3000,4000,5000,6000,7000,8000,9000) or id in (1000,2000,3000,4000,5000,6000,7000,8000,9000)) and deleted is null order by id";
				$exp_worktype_big_list = $this->SysParams->generateList(
						$condition5);
				$data['SysParams50']['name'][$i] = $this->Valid->getOptionValue(
						$setdata, 'MemberExpWorktype/exp_worktype_big',
						$exp_worktype_big_list);
			}
		
			if (!empty($data['MemberExpWorktype']['exp_worktype_small'][$i])) {
				$setdata['MemberExpWorktype']['exp_worktype_small'] = $data['MemberExpWorktype']['exp_worktype_small'][$i];
				$p = $data['MemberExpWorktype']['exp_worktype_big'][$i];
				if ($this->Valid->number($p)) {
					$condition6 = "kbn = 'shokusyu_id' and pid=" . $p;
					$exp_worktype_small_list = $this->SysParams->generateList(
							$condition6);
				}
				$data['SysParams60']['name'][$i] = $this->Valid->getOptionValue(
						$setdata, 'MemberExpWorktype/exp_worktype_small',
						$exp_worktype_small_list);
			}
		}
		
		return $data;
	}
	
	/**
	 *　画面A-2へ遷移するとき呼び出す
	 *
	 * create：????-??-?? zhufeng
	 * update：2012-02-22 ツバサ（エスワイシステム）
	 * */
	function remmember() {
		$this->pageTitle = "カモメ中国転職：登録情報";
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		} else {
			
			//lfx modified 2013-09-12 start
			//$data1 = $this->News->findAll("display_obj_m = '1' and deleted is null order by contribute_date desc");
			$data1 = $this->News->findAll("display_obj_m = '1' and deleted is null and cn_asia<>'1' order by contribute_date desc");
			//lfx modified 2013-09-12 end 
			$this->set("message1",$data1);
			$pwdcheck = $this->Member->find("\"Member\".pwd_check_flg in ('1','2','3') and \"Member\".id=".Sanitize::sql($id));

			$scoutMsgReactionInfoSQL= "select count(id) as cnt, max(received) as max_r from scout_msg_reaction_info where member_id="
				. $id . " and received >= (now()-interval '7 day')::date and status='0' and deleted is null and member_deleted is null";

			$resultScout = $this->ScoutMsgReactionInfo->query($scoutMsgReactionInfoSQL);
			if(!empty($resultScout)){
				$this->set("message2","スカウトメールが届きました。");
				$this->set("time2",$resultScout[0][0]['max_r']);
				$this->set("count2",$resultScout[0][0]['cnt']);
			}else {
				$this->set("message2",null);
			}

			$webMsgSQL = "select count(id) as cnt, max(received) as max_w from web_msg_info where member_id="
			        . $id . " and received >= (now()-interval '7 day')::date and status='0' and mail_from = '0' and deleted is null and member_deleted is null";

			$resultWebMsg = $this->ScoutMsgReactionInfo->query($webMsgSQL);
			
			if(!empty($resultWebMsg)){
				$this->set("message3","WEBメッセージを受信しました。");
				$this->set("time3", $resultWebMsg[0][0]['max_w']);
				$this->set("count3", $resultWebMsg[0][0]['cnt']);
			}else{
				$this->set("message3",null);
			}		

			//2013/1/7 Enhance対応 By nan Start
			$noticeMsgReactionInfoSQL= "select count(id) as cnt, max(received) as max_r from notice_msg_reaction_info where member_id="
			. $id . " and received >= (now()-interval '7 day')::date and status='0' and deleted is null and member_deleted is null";
			
			$resultNotice = $this->ScoutMsgReactionInfo->query($noticeMsgReactionInfoSQL);
			if(!empty($resultScout)){
				$this->set("message4","告知メールが届きました。");
				$this->set("time4",$resultNotice[0][0]['max_r']);
				$this->set("count4",$resultNotice[0][0]['cnt']);
			}else {
				$this->set("message4",null);
			}
			//2013/1/7 Enhance対応 By nan end
						
			if (!empty($pwdcheck)) {
				$this->set("last_pwd_modified",$pwdcheck['Member']['last_pwd_modified']);
				if($pwdcheck['Member']['pwd_check_flg']=='1') {
					$this->set("pwdcheck",$this->Valid->error("password_overtime"));
					$this->Valid->error("password_overtime");
				} elseif ($pwdcheck['Member']['pwd_check_flg']=='2') {
					$this->set("pwdcheck",$this->Valid->error("password_str_num_mem"));
				} else {
					$this->set("pwdcheck",$this->Valid->error("password_both_mem"));
				}
			}
			
			$member = $this->Member->find(
					"\"Member\".id=" . $id . " and \"Member\".deleted is null");
			$member['Member']['public_profile'] = $this->setPublicProfileFlg(
					$member['Member']['public_profile_flg']);
			
			//nan 2013/1/5 Enhance対応  特別公開の修正 start
			if($member['Member']['public_profile_flg'] == 1) {
				$special = $this->SpecialPublicInfo->find(
						"\"SpecialPublicInfo\".member_id=" . $id . " and \"SpecialPublicInfo\".deleted is null
						and \"SpecialPublicInfo\".public_flg = '1' ");
				if($special != null) {
					$member['Member']['public_profile'] .= '<br><font color="red">※ただし一部特別公開する企業あり</font>'; 
				}	
			}
			//nan 2013/1/5 Enhance対応  特別公開の修正 end
			
			$this->set("member", $member);
			$this->render("remmember");
			exit();
		}
	}
	
	/**
	 * 画面A-2-1へ遷移するとき呼び出す
	 *
	 * create: 2012-02-21　ツバサ（エスワイシステム）
	 * update: 2012-02-24　ツバサ（エスワイシステム）
	 * */
	function remmemberprofile() {
		$this->pageTitle = "求職者-登録プロフィール詳細";
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		} else {
			$member = $this->Member->find(
					"\"Member\".id=" . $id . " and \"Member\".deleted is null");
			$member['Member']['public_profile'] = $this->setPublicProfileFlg(
					$member['Member']['public_profile_flg']); // ツバサ　2012-02-22
			
			//nan 2013/1/5 Enhance対応  特別公開の修正 start
			if($member['Member']['public_profile_flg'] == 1) {
				$special = $this->SpecialPublicInfo->find(
						"\"SpecialPublicInfo\".member_id=" . $id . " and \"SpecialPublicInfo\".deleted is null
						and \"SpecialPublicInfo\".public_flg = '1' ");
				if($special != null) {
					$member['Member']['public_profile'] .= '<br><font color="red">※ただし一部特別公開する企業あり</font>';
				}
			}
			//nan 2013/1/5 Enhance対応  特別公開の修正 end
			
			if($member['Member']['hope_income_flg'] == 2) {
				/* wang.wei 2012/12/10 update start*/
				$this->setIncome($member['Member']['hope_income'], $member['Member']['hope_income_cur'], $member['Member']['hope_income_to'],'hope_income');
				//$this->setIncome($member['Member']['hope_income'], $member['Member']['hope_income_cur']); // ツバサ　2012-02-22
				/* wang.wei 2012/12/10 update end*/
			} else if($member['Member']['hope_income_flg'] == 1) { 
				$member['Member']['hope_income'] = '希望なし';
			} 
			$member['Member']['visa'] = $this->setWorkVisa($member); // ツバサ　2012-02-22
			$this->memberExpToArray($member);
			$expworktype = $this->MemberExpWorktype->findAll( //会員経験職種情報を取得する　ツバサ 2012-02-23
					"\"MemberExpWorktype\".member_id=" . $id . " and \"MemberExpWorktype\".deleted is null",
					null, "MemberExpWorktype.id");
			$edu = $this->MemberEducation->findAll( //ツバサ 2012-03-05
					"\"MemberEducation\".member_id=" . $id . " and \"MemberEducation\".deleted is null",
					null, "MemberEducation.id");
			/* add by wang.wei 2012/12/07 start */
			$mr = $this->Common->getMemberResumeDataByMemberid($id,
					'id,note',
					"\"MemberResume\".id asc");
			$member['MemberResume']['id'] = $mr['MemberResume']['id'];
			$member['MemberResume']['note'] = $mr['MemberResume']['note'];
			/* add by wang.wei 2012/12/07 end */
						
			$this->set("edu", $edu); //ツバサ 2012-03-05
			$this->set("expworktype", $expworktype);
			$this->set("member", $member);
			$this->render("remmemberprofile");
			exit();
		}
	}
	
	/**
	 * 画面A-2-2へ遷移するとき呼び出す
	 *
	 * create: 2012-02-22
	 * update: 2012-02-24
	 * @author ツバサ（エスワイシステム）
	 * */
	function resumeshow() {
		
		
		$this->pageTitle = "求職者-履歴書詳細";
		$id = $this->rdAuth->id;
		if (empty($id)) {
			$this->redirect(FRONT_SERVER_HTTP.FRONT_SERVER_NAME.'/memberLogin/login');
			exit();
		} else {
			$resumeData = $this->getResumeData($id);
			if (empty($resumeData['resume']['MemberResume'])) {
				$this->resume($id);
				exit();
			}
			$this->set("resumeData", $resumeData);
			$this->render("resumeshow");
			exit();
		}
	}
	
	/**
	 *
	 * add 2012/4/7
	 * @author wang.wei
	 * @param new_pwd - check new_pwd is same
	 * @param member_id
	 *
	 **/
	function checkUpdateTheSamePwd($new_pwd, $member_id){
		$message = '';
		$data = $this->Member->find("\"Member\".deleted is null and \"Member\".id=" . $member_id,"login_pwd");
		if(md5($new_pwd) == $data['Member']['login_pwd']){
			$message = $this->Valid->error("update_the_pwd_same");
		}
		return $message;
	}
	
	/**
	 *
	 * add 2012/4/7
	 * @author wang.wei
	 * @param new_pwd - check new_pwd to update lastpwdmodified
	 * @param member_id
	 **/
	function updateLastPwdDate($new_pwd, $member_id){
		if(!empty($new_pwd)){
			$this->Member->updateMemberCon($member_id, "last_pwd_modified = now(), pwd_check_flg = null" );
		}
	}
	
	
	/**
	 * Web ページの有効期限をセットする
	 *
	 * create: 2012-04-24 ツバサ（SY）
	 * */
	private function setHead() {
		header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");
		header("Last-Modified:".gmdate("D, d M Y H:i:s") . " GMT");
		header("Cache-Control: no-cache, must-revalidate");
		header("Pragma: no-cache");
	}
	
	
	
	/**
	 * サニタイズする
	 *
	 * */
	private function changeSpecString(&$str) {
		if(empty($str)) 
			return null;
		
		$str = str_replace("\"","",$str);
		$str = str_replace("'","",$str);
		$str = str_replace(";","",$str);
		$str = str_replace("-","",$str);
		$str = str_replace(",","",$str);
		
		$str = str_replace("%","",$str);
		$str = str_replace("?","",$str);
		$str = str_replace("&","",$str);
		$str = str_replace("(","",$str);
		$str = str_replace(")","",$str);
		$str = str_replace("*","",$str);
		$str = str_replace("+","",$str);
		$str = str_replace("/","",$str);
		$str = str_replace(":","",$str);
		$str = str_replace("<","",$str);
		$str = str_replace("=","",$str);
		$str = str_replace(">","",$str);
		$str = str_replace("_","",$str);
		$str = str_replace("|","",$str);
		$str = str_replace("\\","",$str);
	}
	
	/**
	 * add tsubasa 2012/11/13
	 * 
	 * */
	private function isCountError($memberData = null) {
		if($memberData == null) {
			return false;
		}
		if($memberData['member_overseas_edu_count'] > 3				// 留学経験
			|| !is_numeric($memberData['member_overseas_edu_count'])
			|| $memberData['member_overseas_work_count'] > 3			// 外国での勤務経験
			|| !is_numeric($memberData['member_overseas_work_count'])
			|| $memberData['member_lang_count'] > 5					// 語学レベル
			|| !is_numeric($memberData['member_lang_count'])
			|| $memberData['member_hope_work_location_count'] > 3	// 希望勤務地
			|| !is_numeric($memberData['member_hope_work_location_count'])
			|| $memberData['member_hope_category_count'] > 3			// 希望業種
			|| !is_numeric($memberData['member_hope_category_count'])
			|| $memberData['member_hope_worktype_count'] > 3			// 希望職種
			|| !is_numeric($memberData['member_hope_worktype_count'])
		) {
			return true;
		}
		return false;
	}
	
	/**
	 * 特別公開企業を削除する
	 */
	function delete_special_company() {
		$this->layout = 'ajax';
		$id = $this->rdAuth->id;
		
	    $company_id = $this->params['form']['company_id'];
	    $company_id_list = split(',', $company_id);
		if($id) {
			for($i=0; $i < count($company_id_list); $i++) {
				if(is_numeric($company_id_list[$i])) {
					$this->SpecialPublicInfo->doDeleteSpecialCompany($company_id_list[$i],$id);
				}
			}
		}
		$special = $this->SpecialPublicInfo->getSpecialCompanyByMemberID($id);
		$this->set("myMember", $special);
		$this->render("ajax_special_company");
	}
	
}
?>